35 lines
946 B
Python
35 lines
946 B
Python
#!/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)
|
|
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)
|