Skip to main content

Perform CRUD operations with SQLAlchemy

Project description

Perform Create, Update, Read, and Delete operations easily using the SQLAlchemy orm

Installation

To install via pip:

pip install sqlalchemybulk

Or download the source code and install manually:

git clone https://github.com/sudonorm/sqlalchemy-bulk.git
cd sqlalchemy-bulk/
python -m pip install .

Or download the dource code and use the setup.py file:

git clone https://github.com/sudonorm/sqlalchemy-bulk.git
cd sqlalchemy-bulk/
python setup.py install

Basic usage

from sqlalchemybulk.crud_helper_funcs import UploadData, DownloadData, DeleteData
import pandas as pd
from sqlalchemy import select, delete
from tests.sample_data.dataModel import engine
from tests.sample_data import dataModel

## Insert (Create) or Update
upload_data = UploadData(engine=engine)
returned_ids = upload_data.upload_info_atomic(dbTable='dataModel.Address', df=df, unique_idx_elements=['name', 'postalZip'], column_update_fields=['address', 'country', 'suptext', 'numberrange', 'currency', 'alphanumeric'])

## Download (Read)
download_data = DownloadData(engine=engine)

### query full table
query = select(dataModel.Address)
result = download_data.download_info_using_session(statement=query)

### query with filter
query = select(dataModel.Address).where(dataModel.Address.postalZip == "3778")
result = download_data.download_info_using_session(statement=query)

## Delete
delete_data = DeleteData(engine=engine)
query = delete(dataModel.Address).where(dataModel.Address.postalZip == "15143")
delete_data.delete_data_on_condition(dbTable="dataModel.Address", statement=query)

Bugs, requests, questions, etc.

Please create an issue on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlalchemybulk-0.1.4.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

sqlalchemybulk-0.1.4-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file sqlalchemybulk-0.1.4.tar.gz.

File metadata

  • Download URL: sqlalchemybulk-0.1.4.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for sqlalchemybulk-0.1.4.tar.gz
Algorithm Hash digest
SHA256 675229b1d2479764bbbda2302915087f30b3de426f75f53bbb6884c2a1697834
MD5 82118f83e895a508d7f5e1da81cdd4ed
BLAKE2b-256 f08d860fcf96525910b9f7673250de3aafda7c267e9c8a04f2e5b7619c54fcc2

See more details on using hashes here.

File details

Details for the file sqlalchemybulk-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for sqlalchemybulk-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2f5b76f0a1a090b22f5938daf9e83d3e0492683c265571e28b4171fe18f53dc2
MD5 d7ddc7b133d4900b313c79d3610982ba
BLAKE2b-256 9eda2033e9987be74a47e59cd90e47fd7a156464c4cab9d2475a38a8a389ee88

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page