[egenix-users] mxODBC - How do I "set schema"?
M.-A. Lemburg
mal at egenix.com
Tue Feb 1 08:55:06 CET 2005
Bob Gibson wrote:
>
>
>
> 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?
Nothing. The -1 return value is from the old days when .execute()
used to return the number of affected rows (or -1 in case the
statement did not affect any).
With DB-API 2.0 you should always use .rowcount instead.
> ----------------------------------------------------------------------
> 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.
>
>
> ------------------------------------------------------------------------
>
>
> _______________________________________________________________________
> 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, Feb 01 2005)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
More information about the egenix-users
mailing list