mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
display_columns_and_rows() no longer uses inspect, refs #420
This commit is contained in:
parent
53bf875483
commit
c882e9262f
3 changed files with 20 additions and 21 deletions
|
|
@ -3,6 +3,7 @@ import hashlib
|
|||
from .utils import (
|
||||
detect_spatialite,
|
||||
detect_fts,
|
||||
detect_primary_keys,
|
||||
escape_sqlite,
|
||||
get_all_foreign_keys,
|
||||
table_columns,
|
||||
|
|
@ -31,19 +32,6 @@ def inspect_views(conn):
|
|||
return [v[0] for v in conn.execute('select name from sqlite_master where type = "view"')]
|
||||
|
||||
|
||||
def detect_primary_keys(conn, table):
|
||||
" Figure out primary keys for a table. "
|
||||
table_info_rows = [
|
||||
row
|
||||
for row in conn.execute(
|
||||
'PRAGMA table_info("{}")'.format(table)
|
||||
).fetchall()
|
||||
if row[-1]
|
||||
]
|
||||
table_info_rows.sort(key=lambda row: row[-1])
|
||||
return [str(r[1]) for r in table_info_rows]
|
||||
|
||||
|
||||
def inspect_tables(conn, database_metadata):
|
||||
" List tables and their row counts, excluding uninteresting tables. "
|
||||
tables = {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue