def test_interval_precision(self): t = Table( 'i_test', self.metadata, Column('id', Integer, primary_key=True), Column('data1', INTERVAL(precision=6)), ) t.create(testing.db) columns = { rec['name']: rec for rec in inspect(testing.db).get_columns("i_test") } assert isinstance(columns["data1"]["type"], INTERVAL) eq_(columns["data1"]["type"].fields, None) eq_(columns["data1"]["type"].precision, 6)
def _test_interval_symbol(self, sym): t = Table( "i_test", self.metadata, Column("id", Integer, primary_key=True), Column("data1", INTERVAL(fields=sym)), ) t.create(testing.db) columns = { rec["name"]: rec for rec in inspect(testing.db).get_columns("i_test") } assert isinstance(columns["data1"]["type"], INTERVAL) eq_(columns["data1"]["type"].fields, sym.lower()) eq_(columns["data1"]["type"].precision, None)
class CrontabberLog(DeclarativeBase): __tablename__ = 'crontabber_log' # column definitions id = Column(u'id', INTEGER(), primary_key=True, nullable=False) app_name = Column(u'app_name', TEXT(), nullable=False) log_time = Column(u'log_time', TIMESTAMP(timezone=True), nullable=False, server_default=text('NOW()')) duration = Column(u'duration', INTERVAL()) success = Column(u'success', TIMESTAMP(timezone=True)) exc_type = Column(u'exc_type', TEXT()) exc_value = Column(u'exc_value', TEXT()) exc_traceback = Column(u'exc_traceback', TEXT()) __table_args__ = ( Index('crontabber_log_app_name_idx', app_name), Index('crontabber_log_log_time_idx', log_time), )
from flask_sqlalchemy import SQLAlchemy from sqlalchemy.dialects.postgresql import INTERVAL, TIMESTAMP, TSTZRANGE, UUID db = SQLAlchemy() db.INTERVAL = INTERVAL() db.TIMESTAMP = TIMESTAMP() db.TSTZRANGE = TSTZRANGE() db.UUID = UUID() class Profile(db.Model): __tablename__ = 'profile' __table_args__ = {'schema': 'account'} id = db.Column(UUID(as_uuid=False), primary_key=True) user_name = db.Column(db.Text) employee_id = db.Column(UUID())