./data 폴더를 모니터랑 하고, 새 파일이 생기면 일치하는 파일 형식인지 찾은 후 데이터를 파싱해서 DB에 저장
This commit is contained in:
@ -18,7 +18,12 @@ db_cfg = config['database']
|
||||
db_url = f"mysql+pymysql://{db_cfg['user']}:{db_cfg['password']}@{db_cfg['host']}/{db_cfg['name']}?charset=utf8mb4"
|
||||
|
||||
# MySQL 연결이 끊겼을 때 자동 재시도 옵션 포함
|
||||
engine = create_engine(db_url, pool_pre_ping=True)
|
||||
engine = create_engine(
|
||||
db_url,
|
||||
pool_pre_ping=True,
|
||||
pool_recycle=3600, # 3600초 = 1시간
|
||||
)
|
||||
|
||||
Session = sessionmaker(bind=engine)
|
||||
|
||||
def get_engine():
|
||||
|
||||
@ -164,6 +164,15 @@ ga4 = Table(
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
|
||||
holiday = Table(
|
||||
get_full_table_name('holiday'), metadata,
|
||||
Column('date', String(8), primary_key=True, comment='날짜 (YYYYMMDD)'),
|
||||
Column('name', String(50), nullable=False, comment='휴일명'),
|
||||
Column('created_at', DateTime, server_default=func.now(), comment='등록일시'),
|
||||
Column('updated_at', DateTime, server_default=func.now(), onupdate=func.now(), comment='수정일시'),
|
||||
comment='한국천문연구원 특일정보'
|
||||
)
|
||||
|
||||
pos = Table(
|
||||
get_full_table_name('pos'), metadata,
|
||||
Column('idx', Integer, primary_key=True, autoincrement=True),
|
||||
@ -180,15 +189,6 @@ pos = Table(
|
||||
UniqueConstraint('date', 'ca01', 'ca02', 'ca03', 'name', 'barcode', name='uniq_pos_composite')
|
||||
)
|
||||
|
||||
holiday = Table(
|
||||
get_full_table_name('holiday'), metadata,
|
||||
Column('date', String(8), primary_key=True, comment='날짜 (YYYYMMDD)'),
|
||||
Column('name', String(50), nullable=False, comment='휴일명'),
|
||||
Column('created_at', DateTime, server_default=func.now(), comment='등록일시'),
|
||||
Column('updated_at', DateTime, server_default=func.now(), onupdate=func.now(), comment='수정일시'),
|
||||
comment='한국천문연구원 특일정보'
|
||||
)
|
||||
|
||||
pos_billdata = Table(
|
||||
get_full_table_name('pos_billdata'), metadata,
|
||||
Column('sale_date', Date, nullable=False),
|
||||
@ -197,7 +197,7 @@ pos_billdata = Table(
|
||||
Column('bill_no', Integer, nullable=False),
|
||||
Column('product_cd', String(20), nullable=False),
|
||||
Column('division', String(10)),
|
||||
Column('table_no', Integer),
|
||||
Column('table_no', String(20)),
|
||||
Column('order_time', Time),
|
||||
Column('pay_time', Time),
|
||||
Column('barcode', String(20)),
|
||||
|
||||
Reference in New Issue
Block a user