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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqlalchemybulk-0.1.2.tar.gz
  • Upload date:
  • Size: 17.4 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.2.tar.gz
Algorithm Hash digest
SHA256 09ff6511e022c09099555dc98df92c2fe6b83f687d7451a2a52c57dd42e81e9d
MD5 5214b9b59f078f761020f05cf4f57832
BLAKE2b-256 d99e6c90c5d765eac39c79c2bff898272711b84ea6a7a63f2a44f6dd65af5152

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sqlalchemybulk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1f1f40d10e4978a0f079efab3e8ee2975d875b41b36a718ff9ddfdb71de0adf9
MD5 0efedf53a2cbd2b12d1357ed23e8e1d3
BLAKE2b-256 2287536b0c9833547ed175930561a1d4f3442956669030ded59175d72241a632

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