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

31 lines
802 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)
rate = Column(Float, default=1400)
def __repr__(self):
return "<Person(name='%s', work='%s', rate='%f')>" % (self.name, self.work, self.rate)
if __name__ == '__main__':
engine = create_engine('sqlite:///data.db', echo=True)
Base.metadata.create_all(engine, checkfirst=True)