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
# Upsert function for pandas to_sql with postgres | |
# https://stackoverflow.com/questions/1109061/insert-on-duplicate-update-in-postgresql/8702291#8702291 | |
# https://www.postgresql.org/docs/devel/sql-insert.html#SQL-ON-CONFLICT | |
import pandas as pd | |
import sqlalchemy | |
import uuid | |
import os | |
def upsert_df(df: pd.DataFrame, table_name: str, engine: sqlalchemy.engine.Engine): |
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
# INSTALL DEPENDENCIES BEFORE RUNNING: pandas, sqlite3, sqlalchemy, requests | |
# There is one thing you have to do though: gnucash needs to know the price's currency and it needs a guid (unique identifier) | |
# for this. This guid is unique for each installation, so you need to find yours and assign it to CURRENCY_GUID. | |
# OR: you can just leave it, and the script will fetch the currency from the last price added | |
import pandas as pd | |
import sqlite3 | |
import sqlalchemy | |
from sqlalchemy import create_engine | |
import datetime |