"dfupsert" is a Python package for synchronizing pd.DataFrames with databases using seamless dfupsert (insert or update) operations.
Project description
dfupsert
Overview
dfupsert
is an efficient Python package designed for synchronizing pandas DataFrames with databases using upsert operations (insert or update). It works seamlessly with SQLAlchemy's well-defined table mappings, facilitating a smooth integration between pandas and various databases.
Features
-
Streamlined Upsert Operations: Facilitates upserts directly from pandas DataFrames to database tables using SQLAlchemy mappings.
-
Wide Database Compatibility: Built on top of SQLAlchemy, it supports a diverse range of database systems.
-
Efficient Handling of Large DataSets: Implements chunk-based data processing for optimized performance with large data volumes.
-
Customizable and User-Friendly: Offers flexibility in connection types, table mappings, and chunk sizes to accommodate different use cases.
Installation
Install dfupsert
using pip:
pip install dfupsert
Usage
from dfupsert import upsert
from pandas import DataFrame
from sqlalchemy import create_engine
from your_application.model import YourTableClass # Import your SQLAlchemy table class
# Example DataFrame
data = {'column1': [1, 2], 'column2': [3, 4]}
df = DataFrame(data)
# Establish a database connection using SQLAlchemy
engine = create_engine('your-database-connection-string')
# Upsert DataFrame into the database table
upsert(df=df, con=engine, table=YourTableClass, chunksize=1000)
Requirements
-
Python 3.x
-
pandas
-
SQLAlchemy
Contributing
We welcome contributions to the dfupsert
github project.
License
dfupsert
is available under the MIT License. See the MIT or LICENSE file for more details.
Support
For questions and support, please open an issue in the project's GitHub issue tracker.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file dfupsert-0.0.2.tar.gz
.
File metadata
- Download URL: dfupsert-0.0.2.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cef1cf81e9f6b7ad7d5cc1c0b815c6c2fbe8cb69d6e3b5123d4cdaced661ce5 |
|
MD5 | 914f19b7dcd1c272295fef3bea35f6bc |
|
BLAKE2b-256 | be89468e442c6f19053a4775ed622604885d6b121b6f8d07710ec2f0684494e8 |