export script
This commit is contained in:
@@ -6,7 +6,7 @@ from db.models import Base, Order, OrderStatus
|
||||
|
||||
|
||||
def get_engine():
|
||||
return create_engine('postgresql+psycopg2://postgres:guardia123@192.168.1.202:5432/export-tray', echo=False)
|
||||
return create_engine('postgresql+psycopg2://postgres:guardia123@192.168.1.204:5432/export-tray', echo=False)
|
||||
|
||||
|
||||
def create_tables():
|
||||
@@ -31,6 +31,8 @@ def drop_tables():
|
||||
|
||||
|
||||
Base.metadata.drop_all(engine)
|
||||
|
||||
|
||||
def insert_into_table(values_map, table_name):
|
||||
engine = get_engine()
|
||||
stmt = insert(table_name).values(values_map)
|
||||
@@ -49,3 +51,4 @@ def update_record(where_map, values_map, table_name):
|
||||
result = conn.execute(stmt)
|
||||
print(result)
|
||||
conn.commit()
|
||||
|
||||
|
||||
11
db/models.py
11
db/models.py
@@ -8,6 +8,17 @@ from sqlalchemy.sql import func
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
||||
|
||||
class TrayWebhook(Base):
|
||||
__tablename__ = 'tray_webhook'
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
#create_date: Mapped[datetime] = mapped_column(DateTime, onupdate=func.now(), server_default=func.now())
|
||||
body = Column(String(255))
|
||||
|
||||
|
||||
def __init__(self, body):
|
||||
self.body = body
|
||||
|
||||
|
||||
|
||||
class ApiToken(Base):
|
||||
__tablename__ = 'api_token'
|
||||
|
||||
Reference in New Issue
Block a user