-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.py
More file actions
33 lines (24 loc) · 833 Bytes
/
Copy pathdb.py
File metadata and controls
33 lines (24 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding:utf-8 -*-
from sqlalchemy import create_engine
from sqlalchemy import Column, Integer, String, Text
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
engine = create_engine(
'mysql+pymysql://root:root@127.0.0.1:3306/test',
max_overflow=5,
pool_size=10,
echo=True
)
class Fang(Base):
__tablename__ = 'fang'
id = Column('ID', Integer, primary_key=True)
title = Column('标题', String(64))
unit_type = Column('户型', String(64))
area = Column('面积', String(64))
price = Column('单价', String(64))
year = Column('年代', String(64))
sale_point = Column('卖点', Text())
Base.metadata.create_all(engine)
Session = sessionmaker(bind=engine)
sess = scoped_session(Session)