Created
January 16, 2024 17:45
-
-
Save xescuder/fd764cd82b28b1e8dd75c99c7b3d977a to your computer and use it in GitHub Desktop.
Load CSV into Table
This file contains hidden or 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
import os | |
from pathlib import Path | |
from sqlalchemy import create_engine | |
import pandas as pd | |
from trading_data_pipeline.config import AppConfig | |
config = AppConfig(os.environ) | |
connection_url = config.get_postgres_uri() | |
db = create_engine(connection_url) | |
conn = db.connect() | |
csv_path = os.path.join(str(Path(__file__).parent.parent), 'resources', 'sectors_etfs.csv') | |
data = pd.read_csv(csv_path) | |
data['type'] = 'SECTOR_ETF' | |
data.to_sql('instruments', conn, if_exists='append', index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment