-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost_processing.py
32 lines (26 loc) · 1.09 KB
/
post_processing.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
from sqlalchemy import create_engine, text, MetaData, Table
from sqlalchemy.engine import URL
from tables.parking_spots import insert_representative_coords, insert_prices
from tables.spot_coordinates import get_coordinates
from tables.parking_zones import get_spot_prices
print("Starting post processing the data, please stand by.")
## Change the username below to your own database username
postgres_url = URL.create(
drivername = "postgresql",
username = "Lydia", # change this value
host = "localhost",
database = "parking"
)
postgres_engine = create_engine(postgres_url)
postgres = postgres_engine.connect()
metadata = MetaData()
## getting each parking spot a single pair of coordinates
print("getting all parking spots a set of coordinates")
coordinates = get_coordinates(postgres, postgres_engine, metadata)
insert_representative_coords(postgres, coordinates)
## getting each parking spot a price
print("getting all parking spots a price")
prices = get_spot_prices(postgres, postgres_engine, metadata)
insert_prices(postgres, prices)
postgres.commit()
print("Post processing finished.")