1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Made get_table_list return a TableInfo named tuple

This commit is contained in:
Claude Paroz
2014-09-20 21:34:23 +02:00
parent 463952d940
commit b8cdc7dcc3
5 changed files with 40 additions and 26 deletions

View File

@@ -1,6 +1,6 @@
import re
from django.db.backends import BaseDatabaseIntrospection, FieldInfo
from django.db.backends import BaseDatabaseIntrospection, FieldInfo, TableInfo
field_size_re = re.compile(r'^\s*(?:var)?char\s*\(\s*(\d+)\s*\)\s*$')
@@ -54,14 +54,16 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
data_types_reverse = FlexibleFieldLookupDict()
def get_table_list(self, cursor):
"Returns a list of table names in the current database."
"""
Returns a list of table and view names in the current database.
"""
# Skip the sqlite_sequence system table used for autoincrement key
# generation.
cursor.execute("""
SELECT name FROM sqlite_master
SELECT name, type FROM sqlite_master
WHERE type in ('table', 'view') AND NOT name='sqlite_sequence'
ORDER BY name""")
return [row[0] for row in cursor.fetchall()]
return [TableInfo(row[0], row[1][0]) for row in cursor.fetchall()]
def get_table_description(self, cursor, table_name):
"Returns a description of the table, with the DB-API cursor.description interface."