def get_table_description( self, cursor, table_name ):
qn = self.connection.ops.quote_name
description = []
table_type = 'T'
if not _IS_JYTHON:
dbms_name='dbms_name'
schema = cursor.connection.get_current_schema()
if getattr(cursor.connection, dbms_name) != 'DB2':
sql = "SELECT TYPE FROM SYSCAT.TABLES WHERE TABSCHEMA='%(schema)s' AND TABNAME='%(table)s'" % {'schema': schema.upper(), 'table': table_name.upper()}
else:
sql = "SELECT TYPE FROM SYSIBM.SYSTABLES WHERE CREATOR='%(schema)s' AND NAME='%(table)s'" % {'schema': schema.upper(), 'table': table_name.upper()}
cursor.execute(sql)
table_type = cursor.fetchone()[0]
if table_type != 'X':
cursor.execute( "SELECT * FROM %s FETCH FIRST 1 ROWS ONLY" % qn( table_name ) )
if djangoVersion < (1, 6):
for desc in cursor.description:
description.append( [ desc[0].lower(), ] + desc[1:] )
else:
for desc in cursor.description:
description.append(FieldInfo(*[desc[0].lower(), ] + desc[1:]))
return description
评论列表
文章目录