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

Uploaded Source

Built Distribution

sqlalchemybulk-0.1.1-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqlalchemybulk-0.1.1.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for sqlalchemybulk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 69f702bf2ccb2295fe8fe1bc62a261e4f4e16bbb28c45f899aff80b1e33ae4fe
MD5 86836123e05b2748693f8a8c44ff7c0e
BLAKE2b-256 04951eb5816d91c8c526428eb6ac35c24f9e0ae716103aa8c159469d7718f45a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sqlalchemybulk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8f95f2ff140355e1daf8caae54716ccb49cfe65d5f8cce7c9e402c47d60857ee
MD5 a4b7924fee9ad621a624376dabfd8106
BLAKE2b-256 51b31e4d2a6150b782b1c72e352286c317ec86de3e82813eff404e8fb03c1d7a

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