forked from albertkun/flaskmap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.2.py
49 lines (34 loc) · 1.31 KB
/
models.2.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
from flask_sqlalchemy import SQLAlchemy
DB_URL = 'postgresql+psycopg2://{user}:{pw}@{url}/{db}'.format(user='postgres',pw='yoh',url='localhost:5432',db='postgres')
app.config['SQLALCHEMY_DATABASE_URI'] = DB_URL
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False # silence the deprecation warning
db = SQLAlchemy(app)
# # Import from peewee
# from peewee import *
# # Connect to the PostgresqlDatabase
# from sqlalchemy import create_engine
# engine = create_engine('postgresql://postgres:yoh@localhost:5432/postgres')
# db = PostgresqlDatabase('postgres', user='postgres', password='yoh',
# host='localhost', port=5432)
# # Connect to our database.
# db.connect()
class lasd(Model):
# These are all the fields it has
# match up CharField/IntegerField/etc with correct type
booking_nu = CharField(primary_key=True) # primary key = unique id
sex = CharField()
race = CharField()
charge = CharField()
charge_des = CharField()
charge_lev = CharField()
bail = CharField()
year = CharField()
longitude = DecimalField(null = True)
latitude = DecimalField(null = True)
slug = CharField()
age_categories = CharField()
class Meta:
# data is coming from schools.db
database = db
# and it's in the table called 'events'
db_table = 'lasd_2012_2016'