31 lines
746 B
Python
31 lines
746 B
Python
import psycopg2
|
|
|
|
|
|
from lakewatchscraper import DatabaseSettings, ramps
|
|
from lakewatchscraper.waterdata import ReservoirDayData
|
|
|
|
|
|
def main():
|
|
db_settings = DatabaseSettings.from_env()
|
|
conn = psycopg2.connect(
|
|
dbname=db_settings.dbname,
|
|
user=db_settings.username,
|
|
password=db_settings.password,
|
|
port=db_settings.port,
|
|
host=db_settings.host,
|
|
)
|
|
print("Fetching water data...")
|
|
for row in ReservoirDayData.scrape():
|
|
row.save_to_db(conn)
|
|
print("Finished fetching water data!")
|
|
|
|
print("Fetching ramp data...")
|
|
for ramp in ramps.ramps:
|
|
ramp.fetch_data()
|
|
ramp.save_to_db(conn)
|
|
print("Finished fetching ramp data!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|