Skip to content

Instantly share code, notes, and snippets.

@klogic
Created October 23, 2019 09:50
Show Gist options
  • Save klogic/f33f6f40e09bfc9a3a1dfb067388ecae to your computer and use it in GitHub Desktop.
Save klogic/f33f6f40e09bfc9a3a1dfb067388ecae to your computer and use it in GitHub Desktop.
from datetime import datetime
from random import randrange
from sqlalchemy import DECIMAL, Column, DateTime, Integer, MetaData, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, sessionmaker
from connection import conn
Base = declarative_base()
meta = MetaData(conn).reflect()
dwhConnection = conn.connect()
SessionDwh = sessionmaker(bind=dwhConnection)
sessionDwh = SessionDwh()
class BaseTable(Base):
__tablename__ = 'sales_order'
entity_id = Column(Integer, autoincrement=True, primary_key=True)
amount = Column(DECIMAL(14, 4), nullable=False)
created_at = Column(DateTime(), nullable=False)
def initSalesTable():
isRun = False
if not conn.dialect.has_table(conn, 'sales_order'):
Base.metadata.create_all(bind=conn)
sessionDwh.commit()
isRun = True
return isRun
initSalesTable()
sessionDwh.close()
dwhConnection.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment