-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.py
85 lines (64 loc) · 2 KB
/
db.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import os
from sqlalchemy import create_engine
from sqlalchemy import Table, Column, Integer, String, Float, Boolean
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
engine = create_engine('sqlite:///' + os.getcwd() + '/data/store.db', echo=False)
class Business(Base):
__tablename__ = 'businesses'
id = Column(Integer, primary_key=True)
bid = Column(String, unique=True)
stars = Column(Integer)
review_count = Column(Integer)
latitude = Column(Float)
longitude = Column(Float)
Not = Column(Integer)
good = Column(Integer)
food = Column(Integer)
place = Column(Integer)
like = Column(Integer)
out = Column(Integer)
great = Column(Integer)
very = Column(Integer)
really = Column(Integer)
about = Column(Integer)
go = Column(Integer)
time = Column(Integer)
back = Column(Integer)
service = Column(Integer)
dont = Column(Integer)
social_network_feature = Column(Float)
success = Column(Integer)
def __repr__(self):
return '<Business bid=%s>' % (self.bid, )
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
uid = Column(String, unique=True)
review_count = Column(Integer)
num_fans = Column(Integer)
years_elite = Column(Integer)
funny = Column(Integer)
useful = Column(Integer)
cool = Column(Integer)
def __repr__(self):
return '<User uid=%s>' % (self.uid, )
class Tip(Base):
__tablename__ = 'tips'
id = Column(Integer, primary_key=True)
uid = Column(String)
bid = Column(String)
likes = Column(Integer)
def __repr__(self):
return '<Tip bid=%s uid=%s>' % (self.bid, self.uid)
class userAndRespect(object):
def __init__(self, count,id):
self.count = count
self.id = id
return
def __cmp__(self, other):
return cmp(self.count,other.count)
Base.metadata.create_all(engine)
Session = sessionmaker(bind=engine)
session = Session()