A bit of cleanup

This commit is contained in:
Friedrich Lindenberg 2020-04-06 22:56:35 +02:00
parent 507b0a5a40
commit 9cbdb3772c

View File

@ -2,6 +2,7 @@ from datetime import datetime, date
from sqlalchemy import Integer, UnicodeText, Float, BigInteger
from sqlalchemy import Boolean, Date, DateTime, Unicode, JSON
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.types import TypeEngine
@ -22,19 +23,15 @@ class Types(object):
@property
def json(self):
if self._dialect is not None and self._dialect == 'postgresql':
from sqlalchemy.dialects.postgresql import JSONB
return JSONB
return JSON
def guess(self, sample, dialect = None):
def guess(self, sample):
"""Given a single sample, guess the column type for the field.
If the sample is an instance of an SQLAlchemy type, the type will be
used instead.
"""
if dialect is not None:
self._dialect = dialect
if isinstance(sample, TypeEngine):
return sample
if isinstance(sample, bool):