Re: [SQLObject] Patch to make tableExists work with "db.table" table name
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: David F. <df...@kl...> - 2006-03-08 14:12:37
|
On Tuesday 21 February 2006 15:32, David Faure wrote: > SQLObject currently assumes that a default database was selected for the = connection. > However I'm using SQLObject in a C++ application which executes python sc= ripts, > and the connection doesn't have a default database selected, on purpose. >=20 > With the following naming style I can make SQLObject prepend the database= name > before creating a table or running queries in a table: >=20 > class PrependDBStyle(sqlobject.DefaultStyle): > def pythonClassToDBTable(self, className): > return "sqlobjects." + super(PrependDBStyle, self).pythonClassToDBTable= (className) > def dbTableToPythonClass(self, table): > if table.startsWith( "sqlobjects." ): > table =3D table[11:] > return super(PrependDBStyle,self).dbTableToPythonClass(table) >=20 > However the tableExists check is currently implemented with "SHOW TABLES"= , which > fails when there is no default database selected. The attached patch uses= "DESCRIBE %s" > instead, which works in both cases ("describe foo" or "describe db.foo") Can the attached patch be considered for inclusion? "DESCRIBE [db.]table" works in all cases (with or without a default databas= e) whereas "SHOW TABLES" needs a default database. =2D-=20 David Faure -- fa...@kd..., df...@kl... KDE/KOffice developer, Qt consultancy projects Klar=E4lvdalens Datakonsult AB, Platform-independent software solutions |