This repository has been archived on 2021-12-30. You can view files and clone it, but cannot push or open issues or pull requests.
ELOStar/lib/db_init.py

35 lines
946 B
Python
Raw Permalink Normal View History

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File : db_init.py
@Author : liuyihui
@Email : liuyihui02@gmail.com
'''
# here put the import lib
from sqlalchemy import create_engine
from sqlalchemy import Column, Integer, String, Float
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Person(Base):
__tablename__ = 'persons'
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String)
work = Column(String, default='')
rate = Column(Float, default=1400.0)
2021-12-30 16:37:58 +08:00
hist = Column(String, default='1400')
count = Column(Integer, default=0)
def __repr__(self):
return "<Person(name='%s', work='%s', rate='%f', count='%d')>" % (
self.name, self.work, self.rate, self.count
)
if __name__ == '__main__':
engine = create_engine('sqlite:///data.db', echo=True)
Base.metadata.create_all(engine, checkfirst=True)