-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
28 lines (20 loc) · 755 Bytes
/
models.py
File metadata and controls
28 lines (20 loc) · 755 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
import os
from sqlalchemy import create_engine, Column, String, Integer, Float
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
engine = create_engine(os.getenv('DATABASE_URL',
'postgresql://user:password@localhost/databasename'))
Base = declarative_base()
class Place(Base):
__tablename__ = 'places'
id = Column(Integer, primary_key=True)
user = Column(Integer)
address = Column(String(32))
latitude = Column(Float)
longitude = Column(Float)
image = Column(String)
def __repr__(self):
return '<Place (%r, %r)>' % self.user, self.address
Base.metadata.create_all(engine)
Session = sessionmaker(bind=engine)
session = Session()