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.3.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqlalchemybulk-0.1.3.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for sqlalchemybulk-0.1.3.tar.gz
Algorithm Hash digest
SHA256 17097c054ce0b98ee47ae6cc22fe059877813900663f9db786845ae5efdd561f
MD5 abca760710a95ea5c671d8ddafe916a2
BLAKE2b-256 53314e2713b2021e6ad29a99b48dd4edd9d9a0c071b6102f17177039eabb7c60

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sqlalchemybulk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 53617359b918288a1424f3daa6466383fe78c85f8082db761fd18a49ce94e470
MD5 9a2a08298efb35bce2be6c922f675cbf
BLAKE2b-256 4894042424252a5c7307de920b4466861f340335504a4c919c4bbdf8577662d7

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