class TimestampSequencedWithIDRecord(Base): __tablename__ = 'timestamp_sequenced_items' # Record ID. id = Column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True, index=True, unique=True, autoincrement=True) # Sequence ID (e.g. an entity or aggregate ID). sequence_id = Column(UUIDType(), nullable=False) # Position (timestamp) of item in sequence. position = Column(DECIMAL(24, 6, 6), nullable=False, unique=False) # Topic of the item (e.g. path to domain event class). topic = Column(Text(), nullable=False) # State of the item (serialized dict, possibly encrypted). data = Column(Text()) __table_args__ = ( Index('timestamp_sequenced_items_sequence_id_position_index', 'sequence_id', 'position', unique=True), Index('timestamp_sequenced_items_position_index', 'position', unique=False), )
class StoredEventRecord(Base): __tablename__ = 'stored_events' # Record ID. id = Column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True, index=True, unique=True) # Originator ID (e.g. an entity or aggregate ID). originator_id = Column(UUIDType(), nullable=False) # Originator version of item in sequence. originator_version = Column(BigInteger().with_variant(Integer, "sqlite"), nullable=False) # Type of the event (class name). event_type = Column(Text(), nullable=False) # State of the item (serialized dict, possibly encrypted). state = Column(Text()) __table_args__ = (Index('stored_events_sequence_id_position_index', 'originator_id', 'originator_version', unique=True), )
class IntegerSequencedNoIDRecord(Base): __tablename__ = 'integer_sequenced_items_noid' # Sequence ID (e.g. an entity or aggregate ID). sequence_id = Column(UUIDType(), primary_key=True) # Position (index) of item in sequence. position = Column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True) # Topic of the item (e.g. path to domain event class). topic = Column(Text(), nullable=False) # State of the item (serialized dict, possibly encrypted). data = Column(Text())
class SqlTimestampSequencedItem(Base): # Explicit table name. __tablename__ = 'timestamp_sequenced_items' # Unique constraint. __table_args__ = UniqueConstraint('sequence_id', 'position', name='time_sequenced_items_uc'), # Primary key. id = Column(Integer, Sequence('integer_sequened_item_id_seq'), primary_key=True) # Sequence ID (e.g. an entity or aggregate ID). sequence_id = Column(UUIDType(), index=True) # Position (timestamp) of item in sequence. position = Column(Float(), index=True) # Topic of the item (e.g. path to domain event class). topic = Column(String(255)) # State of the item (serialized dict, possibly encrypted). data = Column(Text())
class SqlIntegerSequencedItem(Base): __tablename__ = 'integer_sequenced_items' id = Column(Integer, Sequence('integer_sequened_item_id_seq'), primary_key=True) # Sequence ID (e.g. an entity or aggregate ID). sequence_id = Column(UUIDType(), index=True) # Position (index) of item in sequence. position = Column(BigInteger(), index=True) # Topic of the item (e.g. path to domain event class). topic = Column(String(255)) # State of the item (serialized dict, possibly encrypted). data = Column(Text()) # Unique constraint includes 'entity_id' which is a good value # to partition on, because all events for an entity will be in the same # partition, which may help performance. __table_args__ = UniqueConstraint('sequence_id', 'position', name='integer_sequenced_item_uc'),
class ExtendedIntegerSequencedRecord(Base): __tablename__ = 'extended_integer_sequenced_items' id = Column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True) # Sequence ID (e.g. an entity or aggregate ID). sequence_id = Column(UUIDType(), nullable=False) # Position (index) of item in sequence. position = Column(BigInteger(), nullable=False) # Topic of the item (e.g. path to domain event class). topic = Column(String(255), nullable=False) # State of the item (serialized dict, possibly encrypted). state = Column(Text()) # Timestamp of the event. timestamp = Column(DECIMAL(24, 6, 6), nullable=False) # timestamp = Column(DECIMAL(27, 9, 9), nullable=False) # Type of the event (class name). event_type = Column(String(255)) __table_args__ = (Index('integer_sequenced_items_index', 'sequence_id', 'position', unique=True), )
class IntegerSequencedWithIDRecord(Base): __tablename__ = "integer_sequenced_items" # Record ID. id = Column( BigInteger().with_variant(Integer, "sqlite"), primary_key=True, index=True, unique=True, ) # Sequence ID (e.g. an entity or aggregate ID). sequence_id = Column(UUIDType(), nullable=False) # Position (index) of item in sequence. position = Column(BigInteger().with_variant(Integer, "sqlite"), nullable=False) # Topic of the item (e.g. path to domain event class). topic = Column(Text(), nullable=False) # State of the item (serialized dict, possibly encrypted). state = Column(LargeBinary()) __table_args__ = ( Index( "integer_sequenced_items_sequence_id_position_index", "sequence_id", "position", unique=True, ), )
class SqlStoredEvent(Base): # Explicit table name. __tablename__ = 'stored_events' # Unique constraint. __table_args__ = UniqueConstraint('aggregate_id', 'aggregate_version', name='stored_events_uc'), # Primary key. id = Column(Integer, Sequence('stored_event_id_seq'), primary_key=True) # Sequence ID (e.g. an entity or aggregate ID). aggregate_id = Column(UUIDType(), index=True) # Position (timestamp) of item in sequence. aggregate_version = Column(BigInteger(), index=True) # Type of the event (class name). event_type = Column(String(100)) # Timestamp of the event. timestamp = Column(Float()) # State of the item (serialized dict, possibly encrypted). state = Column(Text())
class EntitySnapshotRecord(Base): __tablename__ = 'entity_snapshots' # Application ID. application_name = Column(String(length=32), primary_key=True) # Originator ID (e.g. an entity or aggregate ID). originator_id = Column(UUIDType(), primary_key=True) # Originator version of item in sequence. originator_version = Column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True) # Topic of the item (e.g. path to domain entity class). event_type = Column(Text(), nullable=False) # State of the item (serialized dict, possibly encrypted). state = Column(Text())
class TimestampSequencedNoIDRecord(Base): __tablename__ = 'timestamp_sequenced_items_noid' # Sequence ID (e.g. an entity or aggregate ID). sequence_id = Column(UUIDType(), primary_key=True) # Position (timestamp) of item in sequence. position = Column(DECIMAL(24, 6, 6), primary_key=True) # Topic of the item (e.g. path to domain event class). topic = Column(Text(), nullable=False) # State of the item (serialized dict, possibly encrypted). data = Column(Text()) __table_args__ = ( Index('timestamp_sequenced_items_noid_position_index', 'position', unique=False), )
class StoredEventRecord(db.Model): """ Original definition of StoredEventRecord retrieved from: https://github.com/johnbywater/eventsourcing/blob/b50f1e6c89a6412da3013b5dbc720f159124e92d/eventsourcing/infrastructure/sqlalchemy/records.py#L149-L184 But tweaked to work with Postgres """ __tablename__ = "stored_events" # Application ID. application_name = Column(String(length=32), primary_key=True) # Originator ID (e.g. an entity or aggregate ID). originator_id = Column(UUIDType(), primary_key=True) # Originator version of item in sequence. originator_version = Column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True) # Pipeline ID. pipeline_id = Column(Integer(), nullable=True) # Notification ID. notification_id = Column(BigInteger().with_variant(Integer, "sqlite"), nullable=True) # Topic of the item (e.g. path to domain event class). topic = Column(Text(), nullable=False) # State of the item (serialized dict, possibly encrypted). state = Column(Text()) # Causal dependencies. causal_dependencies = Column(Text()) __table_args__ = (Index( "stored_events_notification_index", "application_name", "pipeline_id", "notification_id", unique=True, ), )
class SqlStoredEvent(Base): __tablename__ = 'stored_events' id = Column(Integer, Sequence('stored_event_id_seq'), primary_key=True) event_id = Column(String(255), index=True) timestamp_long = Column(BigInteger(), index=True) stored_entity_id = Column(String(255), index=True) event_topic = Column(String(255)) event_attrs = Column(Text())
class ForeignEduNews(Base): #User.__table__ __tablename__ = 'sp_foreignedunews' id = Column('id', Integer, primary_key=True) title = Column('title', String(length=1000)) link = Column('link', String(length=1000)) content = Column('content', Text()) source = Column('source', String(length=500)) createtime = Column('createtime', DateTime) modifytime = Column('modifytime', DateTime) number = Column('number', String(length=1000))
class StoredEventRecord(Base): __tablename__ = "stored_events" # Application ID. application_name = Column(String(length=32), primary_key=True) # Originator ID (e.g. an entity or aggregate ID). originator_id = Column(UUIDType(), primary_key=True) # Originator version of item in sequence. originator_version = Column( BigInteger().with_variant(Integer, "sqlite"), primary_key=True ) # Pipeline ID. pipeline_id = Column(Integer(), nullable=True) # Notification ID. notification_id = Column( BigInteger().with_variant(Integer, "sqlite"), nullable=True ) # Topic of the item (e.g. path to domain event class). topic = Column(Text(), nullable=False) # State of the item (serialized dict, possibly encrypted). state = Column(LargeBinary()) # Causal dependencies. causal_dependencies = Column(Text()) __table_args__ = ( Index( "stored_events_notification_index", "application_name", "pipeline_id", "notification_id", unique=True, ), )
class Outcome(Base): __tablename__ = 'ventas' id_e = Column(Integer, primary_key=True) codigo = Column(Integer) id_cliente = Column(Integer, ForeignKey('clientes.documento')) id_vendedor = Column(Integer) productos = Column(Text()) checkIn = Column(Boolean) neto = Column(Integer) total = Column(Integer) metodo_pago = Column(Integer) fecha_e = Column(Date, default=_get_date) cliente = relationship(Client)
class SnapshotRecord(Base): __tablename__ = "snapshots" # Sequence ID (e.g. an entity or aggregate ID). sequence_id = Column(UUIDType(), primary_key=True) # Position (index) of item in sequence. position = Column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True) # Topic of the item (e.g. path to domain entity class). topic = Column(Text(), nullable=False) # State of the item (serialized dict, possibly encrypted). state = Column(LargeBinary())
class EducationNews(Base): #User.__table__�鿴��Ϣ __tablename__ = 'sp_educationnews' id = Column('id', Integer, primary_key=True) title = Column('title', String(length=1000)) link = Column('link', String(length=1000)) content = Column('content', Text()) source = Column('source', String(length=500)) createtime = Column('createtime', DateTime) modifytime = Column('modifytime', DateTime) number = Column('number', String(length=1000)) def __repr__(self): return '{}'.format(self.id)
class IntListType(TypeDecorator): """ Store a list of integers as CSV. **Note:** see :class:`StringListType` for a general discussion about SQLAlchemy types where the Python representation is a list; they can seem slightly unusual. """ impl = Text() @property def python_type(self): return list @staticmethod def _intlist_to_dbstr(intlist: Optional[List[int]]) -> str: if not intlist: return "" return ",".join(str(x) for x in intlist) @staticmethod def _dbstr_to_intlist(dbstr: Optional[str]) -> List[int]: if not dbstr: return [] try: return [int(x) for x in dbstr.split(",")] except (TypeError, ValueError): log.warning( "IntListType: Unable to convert database value of {!r}" " to Python; returning empty list", dbstr) return [] def process_bind_param(self, value: Optional[List[int]], dialect: Dialect) -> str: """Convert things on the way from Python to the database.""" retval = self._intlist_to_dbstr(value) return retval def process_literal_param(self, value: Optional[List[int]], dialect: Dialect) -> str: """Convert things on the way from Python to the database.""" retval = self._intlist_to_dbstr(value) return retval def process_result_value(self, value: Optional[str], dialect: Dialect) -> List[int]: """Convert things on the way from the database to Python.""" retval = self._dbstr_to_intlist(value) return retval
class StoredEventRecord(Base): __tablename__ = 'stored_events' # Application ID. application_id = Column(UUIDType(), primary_key=True) # Originator ID (e.g. an entity or aggregate ID). originator_id = Column(UUIDType(), primary_key=True) # Originator version of item in sequence. originator_version = Column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True) # Partition ID. pipeline_id = Column(Integer(), nullable=False) # Record ID. id = Column(BigInteger().with_variant(Integer, "sqlite"), nullable=False) # Type of the event (class name). event_type = Column(Text(), nullable=False) # State of the item (serialized dict, possibly encrypted). state = Column(Text()) # Causal dependencies. causal_dependencies = Column(Text()) __table_args__ = ( Index( 'stored_events_notification_index', 'application_id', 'pipeline_id', 'id', unique=True ), )
class SnapshotRecord(ActiveRecord): __tablename__ = 'snapshots' # Sequence ID (e.g. an entity or aggregate ID). sequence_id = Column(UUIDType(), primary_key=True) # Position (index) of item in sequence. position = Column(BigInteger(), primary_key=True) # Topic of the item (e.g. path to domain entity class). topic = Column(String(255)) # State of the item (serialized dict, possibly encrypted). data = Column(Text()) __table_args__ = (Index('snapshots_index', 'sequence_id', 'position'), )
class StoredEventRecord(ActiveRecord): __tablename__ = 'stored_events' # Originator ID (e.g. an entity or aggregate ID). originator_id = Column(UUIDType(), primary_key=True) # Originator version of item in sequence. originator_version = Column(BigInteger(), primary_key=True) # Type of the event (class name). event_type = Column(String(100)) # State of the item (serialized dict, possibly encrypted). state = Column(Text()) __table_args__ = Index('index', 'originator_id', 'originator_version'),
class TimestampSequencedItemRecord(ActiveRecord): __tablename__ = 'timestamp_sequenced_items' # Sequence ID (e.g. an entity or aggregate ID). sequence_id = Column(UUIDType(), primary_key=True) # Position (timestamp) of item in sequence. position = Column(Float(), primary_key=True) # Topic of the item (e.g. path to domain event class). topic = Column(String(255)) # State of the item (serialized dict, possibly encrypted). data = Column(Text()) __table_args__ = (Index('timestamp_sequenced_items_index', 'sequence_id', 'position'), )
class Jobstate(Base): __tablename__="jobsstate" id = Column(Integer,Sequence("jobsstate_id_seq"),primary_key=True) scriptname=Column(String(1000)) foldername=Column(String(1000)) scriptcontent=Column(String(1000)) outputinfo=Column(Text()) # startdate=Column(DateTime, default=time.strftime(ISOTIMEFORMAT, time.localtime())) startdate=Column(DateTime) finishdate=Column(DateTime) state=Column(Integer) def __init__(self,scriptname,foldername,state): self.scriptname=scriptname self.foldername=foldername self.state=state def __repr(self): return "<Jobstat('%s')>"%(self.scriptname)
class Jobs_recoder(Base): __tablename__="jobs_recoder" id = Column(Integer,Sequence("jobs_recoder_id_seq"),primary_key=True) logicalpurpose=Column(String(200)) scriptname=Column(String(1000)) foldername=Column(String(1000)) inputdata=Column(String(1000)) outputdata=Column(String(1000)) scriptcontent=Column(String(1000)) outputinfo=Column(Text()) # startdate=Column(DateTime, default=time.strftime(ISOTIMEFORMAT, time.localtime())) startdate=Column(DateTime) finishdate=Column(DateTime) state=Column(Integer) def __init__(self,scriptname,foldername,logicalpurpose,state): if foldername[-1]=="/": foldername=foldername[0:-1] scriptfile=open(foldername+"/"+scriptname,'r') line=scriptfile.readline() if re.search(r"^scriptinputdata=(.*)",line)!=None: self.inputdata=re.search(r"^scriptinputdata=(.*)",line).group(1) else: self.inputdata="unknow" line=scriptfile.readline() if re.search(r"^scriptoutputdata=(.*)",line)!=None: self.outputdata=re.search(r"^scriptoutputdata=(.*)",line).group(1) else: self.outputdata="unknow" # scriptcontent_all=scriptfile.read() # scriptfile.close() # if re.search(r"(.*(\n)*)cmdline=\s*(.*)",scriptcontent_all)!=None: # scriptcontent_cmdline=re.search(r"(.*(\n)*)cmdline=\s*(.*)",scriptcontent_all).group(3) # self.scriptcontent=scriptcontent_cmdline self.scriptname=scriptname self.foldername=foldername self.state=state self.logicalpurpose=logicalpurpose def __repr(self): return "<jobs_recoder('%s')>"%(self.scriptname)
def bitmap_ish(n): tp = Text() return tp.with_variant(postgresql.BIT(n, varying=True), "postgresql")
from sqlalchemy import Column, MetaData, Table from sqlalchemy.dialects import postgresql from sqlalchemy.sql.schema import UniqueConstraint from sqlalchemy.sql.sqltypes import ( Date, Float, Integer, Numeric, SmallInteger, String, Text, ) array_ish = Text() array_ish = array_ish.with_variant(postgresql.ARRAY(Integer), "postgresql") def bitmap_ish(n): tp = Text() return tp.with_variant(postgresql.BIT(n, varying=True), "postgresql") meta = MetaData() schema = [ Table( "prezident_kandidati", meta, Column("datum", Date, nullable=True), Column("ckand", SmallInteger, nullable=False), Column("jmeno", Text, nullable=False),