Skip to content

Commit

Permalink
Merge pull request #17 from olincollege/sv-silver
Browse files Browse the repository at this point in the history
Added a silverdb folder and crosswalk code
  • Loading branch information
ruchadave16 authored Nov 20, 2024
2 parents b69c769 + e6e5d91 commit 35f370a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/night_light/silver_db/crosswalk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from night_light.bronze_db.util import connect_to_duckdb

def generate_silver_crosswalks() -> None:
"""
Creates crosswalk table for the silver database
Rewrites pervious verison of the table if it exists.
"""
db_path = "silver.db"
conn = connect_to_duckdb(db_path)
conn.execute("ATTACH DATABASE 'bronze.db' AS bronze")

query = """
DROP TABLE IF EXISTS crosswalks;
CREATE TABLE crosswalks AS
SELECT OBJECTID, Class_Loc, CrossType, geometry
FROM bronze.crosswalks;
"""

conn.execute(query)
print("Silver table regenerated for crosswalks")

if __name__ == "__main__":
generate_silver_crosswalks()

0 comments on commit 35f370a

Please sign in to comment.