-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
34 lines (26 loc) · 1.09 KB
/
models.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
# models.py
import flask_sqlalchemy, app, os
#app.app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://admin:admin@localhost/postgres'
app.app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URL')
db = flask_sqlalchemy.SQLAlchemy(app.app)
class ChatRoom(db.Model):
id = db.Column(db.Integer, primary_key=True) # key
user = db.Column(db.String(120))
image = db.Column(db.String(200))
message = db.Column(db.String(140))
def __init__(self, u, i, m):
self.user = u
self.image = i
self.message = m
def __repr__(self): # what's __repr__?
return '%s' % self.user + '|><|%s' % self.image + '|><|%s' % self.message
class Users(db.Model):
user = db.Column(db.String(120), primary_key = True)
image = db.Column(db.String(200), primary_key = True)
id = db.Column(db.String(120), primary_key = True) # session id
def __init__(self, u, i, ii):
self.user = u
self.image = i
self.id = ii
def __repr__(self): # what's __repr__?
return '%s' % self.user + '|><|%s' % self.image