chore: add main file and building data points
This commit is contained in:
parent
fa0773ffc5
commit
5f1c895e31
1048576
cmm_points_function_vintage_surface.csv
Normal file
1048576
cmm_points_function_vintage_surface.csv
Normal file
File diff suppressed because it is too large
Load Diff
42
main.py
Normal file
42
main.py
Normal file
@ -0,0 +1,42 @@
|
||||
from hub.imports.geometry_factory import GeometryFactory
|
||||
from hub.helpers.dictionaries import Dictionaries
|
||||
import os
|
||||
import psycopg2
|
||||
|
||||
password = os.getenv('PGPASSWORD')
|
||||
|
||||
input_file = "cmm_points_function_vintage_surface.csv"
|
||||
|
||||
city = GeometryFactory(
|
||||
file_type="csv",
|
||||
path=input_file,
|
||||
year_of_construction_field="anne_cnstr",
|
||||
function_field="code_util",
|
||||
function_to_hub=Dictionaries().montreal_function_to_hub_function,
|
||||
total_floor_area_field="supfi_etag"
|
||||
).city
|
||||
|
||||
|
||||
conn_params = {
|
||||
'host': 'localhost',
|
||||
'port': '5432',
|
||||
'database': 'energydemanddb',
|
||||
'user': 'postgres',
|
||||
'password': password
|
||||
}
|
||||
|
||||
try:
|
||||
conn = psycopg2.connect(**conn_params)
|
||||
print("Connection established successfully.")
|
||||
except psycopg2.Error as e:
|
||||
print(f"An error occurred while connecting to the database: {e}")
|
||||
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT * FROM energy_data LIMIT 5;")
|
||||
results = cursor.fetchall()
|
||||
|
||||
for row in results:
|
||||
print(row)
|
||||
|
||||
cursor.close()
|
||||
conn.close()
|
Loading…
Reference in New Issue
Block a user