chore: add main file and building data points

This commit is contained in:
Majid Rezaei 2024-10-03 18:28:35 -04:00
parent 340b84817a
commit 082b32da68
2 changed files with 1048618 additions and 0 deletions

File diff suppressed because it is too large Load Diff

42
main.py Normal file
View 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()