Changeset 1484
- Timestamp:
- 11/28/05 20:05:32 (4 years ago)
- Files:
-
- django/trunk/AUTHORS (modified) (1 diff)
- django/trunk/django/core/db/backends/ado_mssql.py (modified) (1 diff)
- django/trunk/django/core/db/backends/mysql.py (modified) (1 diff)
- django/trunk/django/core/db/backends/postgresql.py (modified) (1 diff)
- django/trunk/django/core/db/backends/sqlite3.py (modified) (1 diff)
- django/trunk/django/core/db/__init__.py (modified) (1 diff)
- django/trunk/django/core/management.py (modified) (2 diffs)
- django/trunk/docs/django-admin.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/AUTHORS
r1458 r1484 75 75 sopel 76 76 Radek Švarz <http://www.svarz.cz/translate/> 77 Swaroop C H <http://www.swaroopch.info> 77 78 Aaron Swartz <http://www.aaronsw.com/> 78 79 Tom Tobin django/trunk/django/core/db/backends/ado_mssql.py
r1326 r1484 113 113 raise NotImplementedError 114 114 115 def get_table_description(cursor, table_name): 116 raise NotImplementedError 117 115 118 def get_relations(cursor, table_name): 116 119 raise NotImplementedError django/trunk/django/core/db/backends/mysql.py
r1326 r1484 124 124 cursor.execute("SHOW TABLES") 125 125 return [row[0] for row in cursor.fetchall()] 126 127 def get_table_description(cursor, table_name): 128 "Returns a description of the table, with the DB-API cursor.description interface." 129 cursor.execute("SELECT * FROM %s LIMIT 1" % table_name) 130 return cursor.description 126 131 127 132 def get_relations(cursor, table_name): django/trunk/django/core/db/backends/postgresql.py
r1326 r1484 100 100 AND pg_catalog.pg_table_is_visible(c.oid)""") 101 101 return [row[0] for row in cursor.fetchall()] 102 103 def get_table_description(cursor, table_name): 104 "Returns a description of the table, with the DB-API cursor.description interface." 105 cursor.execute("SELECT * FROM %s LIMIT 1" % table_name) 106 return cursor.description 102 107 103 108 def get_relations(cursor, table_name): django/trunk/django/core/db/backends/sqlite3.py
r1326 r1484 125 125 126 126 def get_table_list(cursor): 127 raise NotImplementedError 127 cursor.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name") 128 return [row[0] for row in cursor.fetchall()] 129 130 def get_table_description(cursor, table_name): 131 cursor.execute("PRAGMA table_info(%s)" % table_name) 132 return [(row[1], row[2], None, None) for row in cursor.fetchall()] 128 133 129 134 def get_relations(cursor, table_name): django/trunk/django/core/db/__init__.py
r1213 r1484 36 36 get_random_function_sql = dbmod.get_random_function_sql 37 37 get_table_list = dbmod.get_table_list 38 get_table_description = dbmod.get_table_description 38 39 get_relations = dbmod.get_relations 39 40 OPERATOR_MAPPING = dbmod.OPERATOR_MAPPING django/trunk/django/core/management.py
r1483 r1484 572 572 except NotImplementedError: 573 573 relations = {} 574 cursor.execute("SELECT * FROM %s LIMIT 1" % table_name) 575 for i, row in enumerate(cursor.description): 574 for i, row in enumerate(db.get_table_description(cursor, table_name)): 576 575 column_name = row[0] 577 576 if relations.has_key(i): … … 587 586 except KeyError: 588 587 field_type = 'TextField' 589 yield " # The model-creator script used TextField by default, because" 590 yield " # it couldn't recognize your field type." 588 field_type_was_guessed = True 589 else: 590 field_type_was_guessed = False 591 591 field_desc = '%s = meta.%s(' % (column_name, field_type) 592 592 if field_type == 'CharField': 593 593 field_desc += 'maxlength=%s' % (row[3]) 594 yield ' %s)' % field_desc 594 field_desc += ')' 595 if field_type_was_guessed: 596 field_desc += ' # This is a guess!' 597 yield ' %s' % field_desc 595 598 yield ' class META:' 596 599 yield ' db_table = %r' % table_name django/trunk/docs/django-admin.txt
r1474 r1484 87 87 doesn't yet introspect primary keys. 88 88 89 ``inspectdb`` only works with PostgreSQL and MySQL. Foreign-key detection only 90 works in PostgreSQL. 89 ``inspectdb`` works with PostgreSQL, MySQL and SQLite. Foreign-key detection 90 only works in PostgreSQL. In SQLite, it cannot detect column types; it'll 91 use ``TextField`` for each column. 91 92 92 93 install [modelmodule modelmodule ...]
