代码拉取完成,页面将自动刷新
from peewee import *
import datetime
import settings
if settings.DBENGINE.lower() == 'mysql':
database = MySQLDatabase(
settings.DBNAME,
host=settings.DBHOST,
port=settings.DBPORT,
user=settings.DBUSER,
passwd=settings.DBPASSWORD,
charset='utf8',
use_unicode=True,
)
elif settings.DBENGINE.lower() == 'sqlite3':
database = SqliteDatabase(settings.DBNAME)
elif settings.DBENGINE.lower() == 'postgresql':
database = PostgresqlDatabase(
settings.DBNAME,
user=settings.DBUSER,
password=settings.DBPASSWORD,
host=settings.DBHOST,
charset='utf8',
use_unicode=True,
)
else:
raise AttributeError("Please setup datatbase at settings.py")
class BaseModel(Model):
class Meta:
database = database
class Community(BaseModel):
id = BigIntegerField(primary_key=True)
title = CharField()
link = CharField(unique=True)
district = CharField()
bizcircle = CharField()
tagList = CharField()
onsale = CharField()
onrent = CharField(null=True)
year = CharField(null=True)
housetype = CharField(null=True)
cost = CharField(null=True)
service = CharField(null=True)
company = CharField(null=True)
building_num = CharField(null=True)
house_num = CharField(null=True)
price = CharField(null=True)
city = CharField(null=True)
validdate = DateTimeField(default=datetime.datetime.now)
class Houseinfo(BaseModel):
houseID = CharField(primary_key=True)
title = CharField()
link = CharField()
community = CharField()
years = CharField()
housetype = CharField()
square = CharField()
direction = CharField()
floor = CharField()
taxtype = CharField()
totalPrice = CharField()
unitPrice = CharField()
followInfo = CharField()
decoration = CharField()
validdate = DateTimeField(default=datetime.datetime.now)
class Hisprice(BaseModel):
houseID = CharField()
totalPrice = CharField()
date = DateTimeField(default=datetime.datetime.now)
class Meta:
primary_key = CompositeKey('houseID', 'totalPrice')
class Sellinfo(BaseModel):
houseID = CharField(primary_key=True)
title = CharField()
link = CharField()
community = CharField()
years = CharField()
housetype = CharField()
square = CharField()
direction = CharField()
floor = CharField()
status = CharField()
source = CharField()
totalPrice = CharField()
unitPrice = CharField()
dealdate = CharField(null=True)
updatedate = DateTimeField(default=datetime.datetime.now)
class Rentinfo(BaseModel):
houseID = CharField(primary_key=True)
title = CharField()
link = CharField()
region = CharField()
zone = CharField()
meters = CharField()
other = CharField()
subway = CharField()
decoration = CharField()
heating = CharField()
price = CharField()
pricepre = CharField()
updatedate = DateTimeField(default=datetime.datetime.now)
def database_init():
database.connect()
database.create_tables(
[Community, Houseinfo, Hisprice, Sellinfo, Rentinfo], safe=True)
database.close()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。