From shuying at gmail.com Thu Dec 3 02:06:24 2009 From: shuying at gmail.com (Susan) Date: Thu, 3 Dec 2009 12:06:24 +1100 Subject: [DB-SIG] python connection to Velocis Database Message-ID: <75fa0c3a0912021706q557a8884y4e3909feb75c006c@mail.gmail.com> Hi, Is there a python library for connecting to a Raima Velocis database? Cheers, S From vernondcole at gmail.com Thu Dec 3 02:56:03 2009 From: vernondcole at gmail.com (Vernon Cole) Date: Wed, 2 Dec 2009 18:56:03 -0700 Subject: [DB-SIG] python connection to Velocis Database In-Reply-To: <75fa0c3a0912021706q557a8884y4e3909feb75c006c@mail.gmail.com> References: <75fa0c3a0912021706q557a8884y4e3909feb75c006c@mail.gmail.com> Message-ID: Susan: You failed to mention the platform on which you are running Python. I will assume that you are running Microsoft Windows. I was not aware of Raima before seeing your question, so I have never tried this, but it will probably work... I see in Raima's FAQ that they support both ODBC 3.51 and ADO.NET. ADO can be used to connect to almost anything. If you are running on Windows, I would guess that adodbapi.py can be used, since it is able to use either ODBC or ADO connections. The example in their documentation shows a connection string without a "Provider=" clause, which would imply that they are using an ODBC connection. Learn more about connection strings at http://www.asp101.com/articles/john/connstring/default.asp adodbapi is part of the pywin32 package: http://sourceforge.net/projects/pywin32/ You will need to have Raima client software installed on the workstation. There are also other Python ODBC solutions, for either Windows or Linux. -- Vernon Cole P.S.: Interesting to see that RDM is a registered trademark. I once (1980s) worked for a different database company who had "RDM" registerd to them. I still use that RDM database. Small world. On Wed, Dec 2, 2009 at 6:06 PM, Susan wrote: > Hi, > > Is there a python library for connecting to a Raima Velocis database? > > Cheers, > S > _______________________________________________ > DB-SIG maillist - DB-SIG at python.org > http://mail.python.org/mailman/listinfo/db-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mal at egenix.com Thu Dec 3 11:01:48 2009 From: mal at egenix.com (M.-A. Lemburg) Date: Thu, 03 Dec 2009 11:01:48 +0100 Subject: [DB-SIG] python connection to Velocis Database In-Reply-To: <75fa0c3a0912021706q557a8884y4e3909feb75c006c@mail.gmail.com> References: <75fa0c3a0912021706q557a8884y4e3909feb75c006c@mail.gmail.com> Message-ID: <4B178C8C.5000101@egenix.com> Susan wrote: > Hi, > > Is there a python library for connecting to a Raima Velocis database? According to the web page, Raima supports ODBC 3.51, so you can use our mxODBC database adapters together with the Raima ODBC drivers on almost all platforms supported by Python itself. For single-tier setups (client application and database on the same server or the same platform, e.g. both Windows or both Linux): http://www.egenix.com/products/python/mxODBC/ For multiple-tier setups (client application on a different server or different platform, e.g. Linux and Windows): http://www.egenix.com/products/python/mxODBCConnect/ The mxODBC Connect setup will also help in case you have problems finding an ODBC driver for your client application platform: The mxODBC Connect Client works on most Python platforms without needing an ODBC driver. You only need the ODBC driver on the server side. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Dec 03 2009) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ From shuying at gmail.com Tue Dec 8 06:40:06 2009 From: shuying at gmail.com (Susan) Date: Tue, 8 Dec 2009 16:40:06 +1100 Subject: [DB-SIG] python connection to Velocis Database In-Reply-To: References: <75fa0c3a0912021706q557a8884y4e3909feb75c006c@mail.gmail.com> Message-ID: <75fa0c3a0912072140w7948cd54m6d627c413678c2b7@mail.gmail.com> Thanks Vernon & Marc-Andre for your replies. Your suggestion has been helpful and I am running Microsoft Windows. The following: from win32com.client import Dispatch conn = Dispatch(r'ADODB.Connection') conn.Open("Dsn=xxx;uid=xxx;pwd=xxx") conn.Execute('create table foo (blah char(30) )') conn.Execute("insert into foo values('jenny')") conn.Close() works and creates a table 'foo'. However, a simple select results in an error: from win32com.client import Dispatch conn = Dispatch(r'ADODB.Connection') conn.Open("Dsn=xxx;uid=xxx;pwd=xxx") recset, affected = conn.Execute('select name from tablename') conn.Close() >>> recset, affected = conn.Execute('select name from tablename') Traceback (most recent call last): File "", line 1, in File "", line 3, in Execute File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 272, in _ApplyTypes_ result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args) pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147467259), None) Has anyone who has worked on old, esoteric databases before encountered a similar problem and solved it? .S From carl at personnelware.com Tue Dec 8 06:58:50 2009 From: carl at personnelware.com (Carl Karsten) Date: Mon, 7 Dec 2009 23:58:50 -0600 Subject: [DB-SIG] python connection to Velocis Database In-Reply-To: <75fa0c3a0912072140w7948cd54m6d627c413678c2b7@mail.gmail.com> References: <75fa0c3a0912021706q557a8884y4e3909feb75c006c@mail.gmail.com> <75fa0c3a0912072140w7948cd54m6d627c413678c2b7@mail.gmail.com> Message-ID: <549053140912072158n24cca001sdde3e13061a5eab9@mail.gmail.com> On Mon, Dec 7, 2009 at 11:40 PM, Susan wrote: > Thanks Vernon & Marc-Andre for your replies. Your suggestion has been > helpful and I am running Microsoft Windows. The following: > > from win32com.client import Dispatch > conn = Dispatch(r'ADODB.Connection') > conn.Open("Dsn=xxx;uid=xxx;pwd=xxx") > conn.Execute('create table foo (blah char(30) )') > conn.Execute("insert into foo values('jenny')") > conn.Close() > > works and creates a table 'foo'. > > However, a simple select results in an error: > > from win32com.client import Dispatch > conn = Dispatch(r'ADODB.Connection') > conn.Open("Dsn=xxx;uid=xxx;pwd=xxx") > ?recset, affected = conn.Execute('select name from tablename') > conn.Close() > >>>> recset, affected = conn.Execute('select name from tablename') > Traceback (most recent call last): > ?File "", line 1, in > ?File "", line 3, in Execute > ?File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", > line 272, in _ApplyTypes_ > ? ?result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, > retType, argTypes) + args) > pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, > None, None, 0, -2147467259), None) > > Has anyone who has worked on old, esoteric databases before > encountered a similar problem and solved it? I had to connect to something (i forget exactly what) but it had quircks. I tried this and that, and had the best luck with http://ceodbc.sourceforge.net One of the best parts was getting it patched to work around some hardcoded hack in the odbc driver I was using. get it, try it, join the mail list. -- Carl K From mal at egenix.com Tue Dec 8 11:43:55 2009 From: mal at egenix.com (M.-A. Lemburg) Date: Tue, 08 Dec 2009 11:43:55 +0100 Subject: [DB-SIG] python connection to Velocis Database In-Reply-To: <75fa0c3a0912072140w7948cd54m6d627c413678c2b7@mail.gmail.com> References: <75fa0c3a0912021706q557a8884y4e3909feb75c006c@mail.gmail.com> <75fa0c3a0912072140w7948cd54m6d627c413678c2b7@mail.gmail.com> Message-ID: <4B1E2DEB.9040102@egenix.com> Susan wrote: > Thanks Vernon & Marc-Andre for your replies. Your suggestion has been > helpful and I am running Microsoft Windows. The following: > > from win32com.client import Dispatch > conn = Dispatch(r'ADODB.Connection') > conn.Open("Dsn=xxx;uid=xxx;pwd=xxx") > conn.Execute('create table foo (blah char(30) )') > conn.Execute("insert into foo values('jenny')") > conn.Close() > > works and creates a table 'foo'. > > However, a simple select results in an error: > > from win32com.client import Dispatch > conn = Dispatch(r'ADODB.Connection') > conn.Open("Dsn=xxx;uid=xxx;pwd=xxx") > recset, affected = conn.Execute('select name from tablename') > conn.Close() > >>>> recset, affected = conn.Execute('select name from tablename') > Traceback (most recent call last): > File "", line 1, in > File "", line 3, in Execute > File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", > line 272, in _ApplyTypes_ > result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, > retType, argTypes) + args) > pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, > None, None, 0, -2147467259), None) > > Has anyone who has worked on old, esoteric databases before > encountered a similar problem and solved it? We regularly add work-arounds for ODBC-driver quirks to mxODBC. This also includes providing custom versions supporting older versions of databases or ones that are not in common use. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Dec 08 2009) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ From vernondcole at gmail.com Tue Dec 8 17:49:42 2009 From: vernondcole at gmail.com (Vernon Cole) Date: Tue, 8 Dec 2009 09:49:42 -0700 Subject: [DB-SIG] python connection to Velocis Database In-Reply-To: <75fa0c3a0912072140w7948cd54m6d627c413678c2b7@mail.gmail.com> References: <75fa0c3a0912021706q557a8884y4e3909feb75c006c@mail.gmail.com> <75fa0c3a0912072140w7948cd54m6d627c413678c2b7@mail.gmail.com> Message-ID: Susan: That's not a very good error message, it is true. I suspect that your vendor's ODBC driver may be a bit light on diagnostics. To extract the most information from the exception, try something like this: v v v v v start Python code v v v v v from win32com.client import Dispatch import pywintypes conn = Dispatch(r'ADODB.Connection') def printADOerrors(adoConn): j=adoConn.Errors.Count if j: print 'ADO Errors:(%i)' % j for e in adoConn.Errors: print 'Description: %s' % e.Description print 'Number: %s ' % e.Number try: print 'Number constant:' % adoErrors[e.Number] except: pass print 'Source: %s' %e.Source print 'NativeError: %s' %e.NativeError print 'SQL State: %s' %e.SQLState print '...Testing Sql login...' conn.Open('DSN=test') recset, affected = conn.Execute('select blah from foo') # this should work print 'affected=',affected try: recset, affected = conn.Execute('select blah from xxxx') # this should fail except pywintypes.com_error: printADOerrors(conn) conn.Close() ^ ^ ^ ^ ^ ^ ^ ^ end code ^ ^ ^ ^ ^ I tested this script on my system (The DSN "test" points to my MySQL server) and got the following: v v v v v v console output v v v v v ...Testing Sql login... affected= 1 ADO Errors:(1) Description: [MySQL][ODBC 5.1 Driver][mysqld-5.0.75-0ubuntu10.2]Table 'test.xxxx' doesn't exist Number: -2147217865 Source: Microsoft OLE DB Provider for ODBC Drivers NativeError: 1146 SQL State: S0002 ^ ^ ^ ^ ^ ^ ^ which is much easier to understand. With some luck you too may get something readable. By the way, you can get the exact same results by: v v v v v v v v import adodbapi print '...Testing Sql login...' conn = adodbapi.connect('DSN=test') crsr = conn.cursor() crsr.execute('select blah from foo') # this should work print 'affected=',crsr.rowcount try: crsr.execute('select blah from xxxx') # this should fail except conn.DatabaseError: conn.printADOerrors() conn.close() ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^e Which is, IMHO, somewhat easier. -- Vernon -------------- next part -------------- An HTML attachment was scrubbed... URL: From shuying at gmail.com Tue Dec 8 23:53:29 2009 From: shuying at gmail.com (Susan) Date: Wed, 9 Dec 2009 09:53:29 +1100 Subject: [DB-SIG] python connection to Velocis Database In-Reply-To: References: <75fa0c3a0912021706q557a8884y4e3909feb75c006c@mail.gmail.com> <75fa0c3a0912072140w7948cd54m6d627c413678c2b7@mail.gmail.com> Message-ID: <75fa0c3a0912081453h5c48c468xa7e778f49370a084@mail.gmail.com> Marc-Andre, good to know but given what I know about the company I'm doing this work for, that would be my last resort. Vernon, "a bit light" is a bit of an under statement. :) adodbapi looks somewhat better..but I think the problem lies with the vendor's odbc driver and what "should work" doesn't return any errors, useful or otherwise -- it just doesn't return any useful data where there should have been. On Wed, Dec 9, 2009 at 3:49 AM, Vernon Cole wrote: > Susan: > > That's not a very good error message, it is true. > > I suspect that your vendor's ODBC driver may be a bit light on diagnostics. > > To extract the most information from the exception, try something like this: > v v v v v start Python code v v v v v > from win32com.client import Dispatch > import pywintypes > conn = Dispatch(r'ADODB.Connection') > def printADOerrors(adoConn): > ??????? j=adoConn.Errors.Count > ??????? if j: > ??????????? print 'ADO Errors:(%i)' % j > ??????? for e in adoConn.Errors: > ??????????? print 'Description: %s' % e.Description > ??????????? print 'Number: %s ' % e.Number > ??????????? try: > ??????????????? print 'Number constant:' % adoErrors[e.Number] > ??????????? except: > ??????????????? pass > ??????????? print 'Source: %s' %e.Source > ??????????? print 'NativeError: %s' %e.NativeError > ??????????? print 'SQL State: %s' %e.SQLState > print '...Testing Sql login...' > conn.Open('DSN=test') > recset, affected = conn.Execute('select blah from foo')? # this should work > print 'affected=',affected > try: > ??? recset, affected = conn.Execute('select blah from xxxx') # this should > fail > except pywintypes.com_error: > ??? printADOerrors(conn) > conn.Close() > ^ ^ ^ ^ ^ ^ ^ ^ end code ^ ^ ^ ^ ^ > > I tested this script on my system (The DSN "test" points to my MySQL server) > and got the following: > v v v v v v console output v v v v v > ...Testing Sql login... > affected= 1 > ADO Errors:(1) > Description: [MySQL][ODBC 5.1 Driver][mysqld-5.0.75-0ubuntu10.2]Table > 'test.xxxx' doesn't exist > Number: -2147217865 > Source: Microsoft OLE DB Provider for ODBC Drivers > NativeError: 1146 > SQL State: S0002 > ^ ^ ^ ^ ^ ^ ^ > which is much easier to understand. > > With some luck you too may get something readable. > > By the way, you can get the exact same results by: > v v v v v v v v > import adodbapi > print '...Testing Sql login...' > conn = adodbapi.connect('DSN=test') > crsr = conn.cursor() > crsr.execute('select blah from foo') # this should work > print 'affected=',crsr.rowcount > try: > ??? crsr.execute('select blah from xxxx') # this should fail > except conn.DatabaseError: > ??? conn.printADOerrors() > conn.close() > ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^e > Which is, IMHO, somewhat easier. > -- > Vernon > > > >