Skip to content

Instantly share code, notes, and snippets.

View jnmclarty's full-sized avatar

Jeffrey McLarty jnmclarty

View GitHub Profile
  • Update HISTORY.rst
  • Update version number in my_project/__init__.py
  • Update version number in setup.py
  • Install the package again for local development, but with the new version number:
python setup.py develop
  • Run the tests:
python setup.py test
@jnmclarty
jnmclarty / postgresql_df_upsert.py
Created June 15, 2024 03:10 — forked from gordthompson/postgresql_df_upsert.py
Build a PostgreSQL INSERT … ON CONFLICT statement and upsert a DataFrame
# version 1.2 - 2022-10-04
import pandas as pd
import sqlalchemy as sa
def df_upsert(data_frame, table_name, engine, schema=None, match_columns=None):
"""
Perform an "upsert" on a PostgreSQL table from a DataFrame.
Constructs an INSERT … ON CONFLICT statement, uploads the DataFrame to a