mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-25 02:14:31 +02:00
Improved column type introspection, closes #92
This commit is contained in:
parent
43f1c6ab4e
commit
1125460497
2 changed files with 21 additions and 14 deletions
|
|
@ -1,4 +1,4 @@
|
|||
from .utils import sqlite3, OperationalError, suggest_column_types
|
||||
from .utils import sqlite3, OperationalError, suggest_column_types, column_affinity
|
||||
from collections import namedtuple, OrderedDict
|
||||
import datetime
|
||||
import hashlib
|
||||
|
|
@ -65,15 +65,6 @@ if np:
|
|||
)
|
||||
|
||||
|
||||
REVERSE_COLUMN_TYPE_MAPPING = {
|
||||
"": str, # Columns in views sometimes have type = ''
|
||||
"TEXT": str,
|
||||
"BLOB": bytes,
|
||||
"INTEGER": int,
|
||||
"FLOAT": float,
|
||||
}
|
||||
|
||||
|
||||
class AlterError(Exception):
|
||||
pass
|
||||
|
||||
|
|
@ -457,10 +448,7 @@ class Queryable:
|
|||
@property
|
||||
def columns_dict(self):
|
||||
"Returns {column: python-type} dictionary"
|
||||
return {
|
||||
column.name: REVERSE_COLUMN_TYPE_MAPPING[column.type]
|
||||
for column in self.columns
|
||||
}
|
||||
return {column.name: column_affinity(column.type) for column in self.columns}
|
||||
|
||||
@property
|
||||
def schema(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue