本文整理汇总了Python中sqlalchemy.Date方法的典型用法代码示例。如果您正苦于以下问题:Python sqlalchemy.Date方法的具体用法?Python sqlalchemy.Date怎么用?Python sqlalchemy.Date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sqlalchemy
的用法示例。
在下文中一共展示了sqlalchemy.Date方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Date [as 别名]
def upgrade():
op.create_table('provider_rates',
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('valid_from', sa.DateTime(), nullable=False),
sa.Column('provider', sa.Enum('mmg', 'twilio', 'firetext', 'ses', name='providers'), nullable=False),
sa.Column('rate', sa.Numeric(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('provider_statistics',
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('day', sa.Date(), nullable=False),
sa.Column('provider', sa.Enum('mmg', 'twilio', 'firetext', 'ses', name='providers'), nullable=False),
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('unit_count', sa.BigInteger(), nullable=False),
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_provider_statistics_service_id'), 'provider_statistics', ['service_id'], unique=False)
示例2: __init__
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Date [as 别名]
def __init__(self, ChequeId, Amount, WrtDate, DueDate, Serial,
Status, Cust, Account, TransId, Desc, Date, Delete=False, Id=1):
self.ChequeId = ChequeId
self.Amount = Amount
self.WrtDate = WrtDate
self.DueDate = DueDate
self.Serial = Serial
self.Status = Status
self.Cust = Cust
self.Account = Account
self.TransId = TransId
self.Desc = Desc
self.Date = Date
# self.Delete = Delete
## @}
示例3: test_python_type
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Date [as 别名]
def test_python_type(self):
eq_(types.Integer().python_type, int)
eq_(types.Numeric().python_type, decimal.Decimal)
eq_(types.Numeric(asdecimal=False).python_type, float)
eq_(types.LargeBinary().python_type, util.binary_type)
eq_(types.Float().python_type, float)
eq_(types.Interval().python_type, datetime.timedelta)
eq_(types.Date().python_type, datetime.date)
eq_(types.DateTime().python_type, datetime.datetime)
eq_(types.String().python_type, str)
eq_(types.Unicode().python_type, util.text_type)
eq_(types.Enum("one", "two", "three").python_type, str)
assert_raises(
NotImplementedError, lambda: types.TypeEngine().python_type
)
示例4: test_conn_execute
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Date [as 别名]
def test_conn_execute(self, connection):
from sqlalchemy.sql.expression import FunctionElement
from sqlalchemy.ext.compiler import compiles
class myfunc(FunctionElement):
type = Date()
@compiles(myfunc)
def compile_(elem, compiler, **kw):
return compiler.process(func.current_date())
x = connection.execute(func.current_date()).scalar()
y = connection.execute(func.current_date().select()).scalar()
z = connection.scalar(func.current_date())
q = connection.scalar(myfunc())
assert (x == y == z == q) is True
示例5: test_extract_expression
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Date [as 别名]
def test_extract_expression(self, connection):
meta = self.metadata
table = Table("test", meta, Column("dt", DateTime), Column("d", Date))
meta.create_all(connection)
connection.execute(
table.insert(),
{
"dt": datetime.datetime(2010, 5, 1, 12, 11, 10),
"d": datetime.date(2010, 5, 1),
},
)
rs = connection.execute(
select([extract("year", table.c.dt), extract("month", table.c.d)])
)
row = rs.first()
assert row[0] == 2010
assert row[1] == 5
rs.close()
示例6: define_tables
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Date [as 别名]
def define_tables(cls, metadata):
Table(
"users",
metadata,
Column(
"id", Integer, primary_key=True, test_needs_autoincrement=True
),
Column("name", String(50)),
)
Table(
"stuff",
metadata,
Column(
"id", Integer, primary_key=True, test_needs_autoincrement=True
),
Column("date", Date),
Column("user_id", Integer, ForeignKey("users.id")),
)
示例7: define_tables
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Date [as 别名]
def define_tables(cls, metadata):
Table(
"items",
metadata,
Column(
"item_policy_num",
String(10),
primary_key=True,
key="policyNum",
),
Column(
"item_policy_eff_date",
sa.Date,
primary_key=True,
key="policyEffDate",
),
Column("item_type", String(20), primary_key=True, key="type"),
Column(
"item_id",
Integer,
primary_key=True,
key="id",
autoincrement=False,
),
)
示例8: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Date [as 别名]
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('unavailable_room_report',
sa.Column('record_id', sa.Integer(), nullable=False),
sa.Column('room_id', sa.String(), nullable=True),
sa.Column('date', sa.Date(), nullable=True),
sa.Column('time', sa.String(length=4), nullable=True),
sa.Column('reporter', sa.String(length=15), nullable=True),
sa.Column('reporter_type', sa.String(), nullable=True),
sa.PrimaryKeyConstraint('record_id'),
sa.UniqueConstraint('room_id', 'date', 'time', 'reporter', 'reporter_type', name='unavailable_room_report_uniq')
)
op.drop_index('idx_token', table_name='calendar_tokens')
op.alter_column('identity_verify_requests', 'create_time',
existing_type=postgresql.TIMESTAMP(timezone=True),
nullable=True)
op.create_index(op.f('ix_simple_passwords_time'), 'simple_passwords', ['time'], unique=False)
op.drop_index('idx_host_time', table_name='visit_tracks')
op.create_index('idx_host_time', 'visit_tracks', ['host_id', 'last_visit_time'], unique=False)
# ### end Alembic commands ###
示例9: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Date [as 别名]
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('subscription',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
sa.Column('updated_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True),
sa.Column('cancel_url', sa.String(length=1024), nullable=False),
sa.Column('update_url', sa.String(length=1024), nullable=False),
sa.Column('subscription_id', sa.String(length=1024), nullable=False),
sa.Column('event_time', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
sa.Column('next_bill_date', sa.Date(), nullable=False),
sa.Column('cancelled', sa.Boolean(), nullable=False),
sa.Column('plan', sa.Enum('monthly', 'yearly', name='planenum2'), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('subscription_id'),
sa.UniqueConstraint('user_id')
)
op.add_column('users', sa.Column('trial_expiration', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True))
op.drop_column('users', 'plan_expiration')
op.drop_column('users', 'plan')
op.drop_column('users', 'promo_codes')
# ### end Alembic commands ###
示例10: downgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Date [as 别名]
def downgrade():
alembic.op.add_column('cards', sqlalchemy.Column("lastprinted", sqlalchemy.Date))
示例11: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Date [as 别名]
def upgrade():
storm = alembic.op.create_table("storm",
sqlalchemy.Column("date", sqlalchemy.Date, primary_key=True),
sqlalchemy.Column("twitch-subscription", sqlalchemy.Integer, nullable=False, server_default='0'),
sqlalchemy.Column("twitch-resubscription", sqlalchemy.Integer, nullable=False, server_default='0'),
sqlalchemy.Column("twitch-follow", sqlalchemy.Integer, nullable=False, server_default='0'),
sqlalchemy.Column("twitch-message", sqlalchemy.Integer, nullable=False, server_default='0'),
sqlalchemy.Column("patreon-pledge", sqlalchemy.Integer, nullable=False, server_default='0'),
)
datafile = alembic.context.config.get_section_option("lrrbot", "datafile", "data.json")
with open(datafile) as f:
data = json.load(f)
try:
alembic.op.bulk_insert(storm, [
{'date': datetime.date.fromordinal(data['storm']['date']), 'twitch-subscription': data['storm']['count']}
])
del data['storm']
with open(datafile, 'w') as f:
json.dump(data, f, indent=2, sort_keys=True)
except KeyError:
pass
示例12: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Date [as 别名]
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('milestone',
sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(binary=False), default=uuid.uuid4, nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.Column('date', sa.Date(), nullable=True),
sa.Column('name', sa.String(length=40), nullable=False),
sa.Column('project_id', sqlalchemy_utils.types.uuid.UUIDType(binary=False), default=uuid.uuid4, nullable=True),
sa.Column('task_type_id', sqlalchemy_utils.types.uuid.UUIDType(binary=False), default=uuid.uuid4, nullable=True),
sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
sa.ForeignKeyConstraint(['task_type_id'], ['task_type.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_milestone_project_id'), 'milestone', ['project_id'], unique=False)
op.create_index(op.f('ix_milestone_task_type_id'), 'milestone', ['task_type_id'], unique=False)
# ### end Alembic commands ###
示例13: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Date [as 别名]
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('project', sa.Column('end_date', sa.Date(), nullable=True))
op.add_column('project', sa.Column('start_date', sa.Date(), nullable=True))
# ### end Alembic commands ###
示例14: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Date [as 别名]
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('schedule_item',
sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(binary=False), default=uuid.uuid4, nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.Column('start_date', sa.Date(), nullable=True),
sa.Column('end_date', sa.Date(), nullable=True),
sa.Column('project_id', sqlalchemy_utils.types.uuid.UUIDType(binary=False), default=uuid.uuid4, nullable=True),
sa.Column('task_type_id', sqlalchemy_utils.types.uuid.UUIDType(binary=False), default=uuid.uuid4, nullable=True),
sa.Column('entity_id', sqlalchemy_utils.types.uuid.UUIDType(binary=False), default=uuid.uuid4, nullable=True),
sa.ForeignKeyConstraint(['entity_id'], ['task_type.id'], ),
sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
sa.ForeignKeyConstraint(['task_type_id'], ['task_type.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_schedule_item_entity_id'), 'schedule_item', ['entity_id'], unique=False)
op.create_index(op.f('ix_schedule_item_project_id'), 'schedule_item', ['project_id'], unique=False)
op.create_index(op.f('ix_schedule_item_task_type_id'), 'schedule_item', ['task_type_id'], unique=False)
# ### end Alembic commands ###
示例15: test_get_type_of_fields
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Date [as 别名]
def test_get_type_of_fields(resources):
table = sa.Table(
'Test', sa.MetaData(),
sa.Column('integer', sa.Integer, primary_key=True),
sa.Column('text', sa.Text),
sa.Column('float', sa.Float),
sa.Column('date', sa.Date),
sa.Column('boolean', sa.Boolean),
sa.Column('json', postgresql.JSON),
)
fields = ['integer', 'text', 'float', 'date', 'boolean', 'json', ]
data_type_fields = resources.get_type_of_fields(fields, table)
expected_type_fields = {
'integer': rc.TEXT_FIELD.value,
'text': rc.TEXT_FIELD.value,
'float': rc.NUMBER_FIELD.value,
'date': rc.DATE_FIELD.value,
'boolean': rc.BOOLEAN_FIELD.value,
'json': rc.JSON_FIELD.value,
}
assert data_type_fields == expected_type_fields
fields = None
data_type_fields = resources.get_type_of_fields(fields, table)
expected_type_fields = {
'integer': rc.TEXT_FIELD.value,
}
assert data_type_fields == expected_type_fields
# TODO: added Mongo