[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/common/src/dbdrivers/odbc-db2 DBdriver.py
From: |
Jason Cater |
Subject: |
gnue/common/src/dbdrivers/odbc-db2 DBdriver.py |
Date: |
Tue, 29 Jan 2002 11:56:12 -0500 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Jason Cater <address@hidden> 02/01/29 11:56:11
Modified files:
common/src/dbdrivers/odbc-db2: DBdriver.py
Log message:
changed odbc-db2 to support the 'os/390' style system catalogs
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/dbdrivers/odbc-db2/DBdriver.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
Patches:
Index: gnue/common/src/dbdrivers/odbc-db2/DBdriver.py
diff -c gnue/common/src/dbdrivers/odbc-db2/DBdriver.py:1.2
gnue/common/src/dbdrivers/odbc-db2/DBdriver.py:1.3
*** gnue/common/src/dbdrivers/odbc-db2/DBdriver.py:1.2 Mon Jan 28 19:57:15 2002
--- gnue/common/src/dbdrivers/odbc-db2/DBdriver.py Tue Jan 29 11:56:11 2002
***************
*** 16,22 ****
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # Copyright 2000, 2001 Free Software Foundation
#
# FILE:
# odbc-db2/DBdriver.py
--- 16,22 ----
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # Copyright 2000-2002 Free Software Foundation
#
# FILE:
# odbc-db2/DBdriver.py
***************
*** 51,58 ****
def getSchemaTypes(self):
return [ ('table', 'Table',1),
('view', 'View', 1),
! ('alias', 'Alias',1),
! ('summary', 'Summary Table',1) ]
# Return a list of Schema objects
--- 51,57 ----
def getSchemaTypes(self):
return [ ('table', 'Table',1),
('view', 'View', 1),
! ('alias', 'Alias',1) ]
# Return a list of Schema objects
***************
*** 60,77 ****
where_user = ""
if type == None:
! where_type = ['A','S','T','V']
else:
where_type = [string.upper(type[0])]
statement = \
! "select tabschema||'.'||tabname||'.'||type full_name, " + \
! "tabschema||'.'||tabname table_name, " + \
! "type table_type " + \
! "from syscat.tables where type in ('%s') and status = 'N' %s " \
% (string.join(where_type,"','"), where_user) + \
! "order by tabname "
GDebug.printMesg(5,statement)
--- 59,76 ----
where_user = ""
if type == None:
! where_type = ['A','T','V']
else:
where_type = [string.upper(type[0])]
statement = \
! "select creator||'.'||name||'.'||type, " + \
! "creator||'.'||name, " + \
! "type " + \
! "from sysibm.systables where type in ('%s') %s " \
% (string.join(where_type,"','"), where_user) + \
! "order by name "
GDebug.printMesg(5,statement)
***************
*** 80,87 ****
list = []
for rs in cursor.fetchall():
! list.append(GDataObjects.Schema(attrs={'id':string.lower(rs[0]),
'name':rs[1],
! 'type':rs[2]},
getChildSchema=self.__getFieldSchema))
cursor.close()
--- 79,87 ----
list = []
for rs in cursor.fetchall():
! list.append(GDataObjects.Schema(attrs={'id':rs[0],
! 'name':rs[1],
! 'type':{'A':'alias','T':'table','V':view'}[rs[2]]},
getChildSchema=self.__getFieldSchema))
cursor.close()
***************
*** 91,111 ****
# Find a schema object with specified name
def getSchemaByName(self, name, type=None):
- where_user = ""
parts = string.split(string.upper(name),'.')
name = parts[-1]
if len(parts) > 1:
! schema = " and tabschema='%s'" % parts[-2]
else:
! schema = ""
statement = \
! "select tabschema||'.'||tabname||'.'||type full_name, " + \
! "tabschema||'.'||tabname table_name, " + \
! "type table_type " + \
! "from syscat.tables where tabname == '%s' and status = 'N' %s " \
! % (name, schema) + \
! "order by tabname "
GDebug.printMesg(5,statement)
--- 91,110 ----
# Find a schema object with specified name
def getSchemaByName(self, name, type=None):
parts = string.split(string.upper(name),'.')
name = parts[-1]
if len(parts) > 1:
! creator = " and creator='%s'" % parts[-2]
else:
! creator = ""
statement = \
! "select creator||'.'||name||'.'||type, " + \
! "creator||'.'||name, " + \
! "type " + \
! "from sysibm.systables where name == '%s' %s " \
! % (name, creator) + \
! "order by name "
GDebug.printMesg(5,statement)
***************
*** 114,121 ****
list = []
for rs in cursor.fetchall():
! list.append(GDataObjects.Schema(attrs={'id':string.lower(rs[0]),
'name':rs[1],
! 'type':rs[2]},
getChildSchema=self.__getFieldSchema))
cursor.close()
--- 113,120 ----
list = []
for rs in cursor.fetchall():
! list.append(GDataObjects.Schema(attrs={'id':rs[0], 'name':rs[1],
! 'type':{'A':'alias','T':'table','V':view'}[rs[2]]},
getChildSchema=self.__getFieldSchema))
cursor.close()
***************
*** 130,158 ****
# Get fields for a table
def __getFieldSchema(self, parent):
! # TODO: This does not support user-defined datatypes...
! # TODO: it will always report such as TEXT-like fields.
! schema, name, type = string.split(parent.id,'.')
cursor = self._dataConnection.cursor()
! if type == 'a':
! statement = "select base_tabschema, base_tabname " + \
! "from syscat.tables " + \
! "where tabschema = '%s' and tabname='%s'" % (schema, name)
GDebug.printMesg(5,statement)
cursor.execute(statement)
rs = cursor.fetchone()
! schema, name = rs
statement = \
! "select tabschema||'.'||tabname||'.'||colname, " + \
! "colname, typename, nulls, length, scale, typeschema " + \
! "from syscat.columns" + \
! "where tabschema = '%s' and tabname = '%s' " % (schema, name) + \
"order by colno"
GDebug.printMesg(5,statement)
--- 129,158 ----
# Get fields for a table
def __getFieldSchema(self, parent):
! # TODO: This does not support aliases that point to remote databases
! # TODO: I have no clue how to attach to a remote database to grab
! # TODO: the "real" table's column information :(
! creator, name, type = string.split(parent.id,'.')
cursor = self._dataConnection.cursor()
! if type == 'A':
! statement = "select tbcreator, tbname " + \
! "from sysibm.systables " + \
! "where creator = '%s' and name='%s'" % (creator, name)
GDebug.printMesg(5,statement)
cursor.execute(statement)
rs = cursor.fetchone()
! creator, name = rs
statement = \
! "select tbcreator||'.'||tbname||'.'||name, " + \
! "name, coltype, nulls, length, scale " + \
! "from sysibm.syscolumns" + \
! "where tbcreator = '%s' and tbname = '%s' " % (creator, name) + \
"order by colno"
GDebug.printMesg(5,statement)
- gnue/common/src/dbdrivers/odbc-db2 DBdriver.py,
Jason Cater <=