-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : add script for loading positions of the test dataset
- Loading branch information
Ronan
committed
Feb 12, 2024
1 parent
be4a194
commit 52526b1
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import logging | ||
import os | ||
from pathlib import Path | ||
|
||
import pandas as pd | ||
from sqlalchemy import create_engine | ||
|
||
logging.basicConfig() | ||
logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO) | ||
|
||
postgres_user = os.environ.get("POSTGRES_USER") | ||
postgres_password = os.environ.get("POSTGRES_PASSWORD") | ||
postgres_hostname = os.environ.get("POSTGRES_HOSTNAME") | ||
postgres_db = os.environ.get("POSTGRES_DB") | ||
postgres_port = os.environ.get("POSTGRES_PORT") | ||
|
||
# The db url is configured with the db connexion variables declared in the db.yaml file. | ||
db_url = ( | ||
"postgresql://" | ||
+ postgres_user | ||
+ ":" | ||
+ postgres_password | ||
+ "@" | ||
+ postgres_hostname | ||
+ ":" | ||
+ postgres_port | ||
+ "/" | ||
+ postgres_db | ||
) | ||
engine = create_engine(db_url) | ||
df = pd.read_csv( | ||
Path.joinpath(Path.cwd(), "spire_positions_subset_02022024.csv"), | ||
sep="," | ||
) | ||
|
||
df.to_sql("spire_vessel_positions", engine, if_exists="append", index=False) |