API to help make public data easier to access. Idea started with need for King County, WA COVID-19 data in API format while only having an excel file for source data.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

30 lines
726 B

import psycopg2
import creds
# assign secrets to variables
dbhost = creds.dblogin['host']
database = creds.dblogin['db']
username = creds.dblogin['username']
password = creds.dblogin['password']
port = creds.dblogin['port']
conn = psycopg2.connect(f"host={dbhost} dbname={database} user={username} password={password} port={port}")
cur = conn.cursor()
cur.execute("""
CREATE TABLE king_county_covid19_zip(
id SERIAL PRIMARY KEY,
date_added DATE NOT NULL DEFAULT CURRENT_DATE,
date_data DATE,
zipcode TEXT,
population INTEGER,
tests INTEGER,
test_rate TEXT,
positives INTEGER,
positive_rate TEXT,
hospitalizations INTEGER,
hospitalization_rate TEXT,
deaths INTEGER,
death_rate TEXT)
""")
conn.commit()