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 source code and use the setup.py file:

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

Be sure to add a .env to the root of the project with at least these variables (DB_URI, ALEMBIC_PATH):

DB_URI="postgresql+psycopg2://username:password@host:port/database_name"
ALEMBIC_PATH="<path/to/user/project/root/folder>"

# "SQLITE_DB_PATH" is optional, except you are testing with a SQLite DB.

SQLITE_DB_PATH="<path/to/user/folder>/test.db"

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqlalchemybulk-0.1.7-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqlalchemybulk-0.1.7.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for sqlalchemybulk-0.1.7.tar.gz
Algorithm Hash digest
SHA256 9a2ce4a9e71075e654a6fbe87e8a3f2cba66a23f3e58852da5d501bd4be99e4e
MD5 d9cf6930d722f25bbdae7aafcfc23c19
BLAKE2b-256 12f0dd89da37819518ed8156e336d962adf6027f9553c4657f3057297a9e123b

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlalchemybulk-0.1.7.tar.gz:

Publisher: update_pypi_package.yml on sudonorm/sqlalchemy-bulk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: sqlalchemybulk-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for sqlalchemybulk-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 babcd575eac51ce1d149735f3dfb36ac11d6b47b2f265facd92dcacc0d8b99bc
MD5 87eecaf5eea73883ac882f2913507993
BLAKE2b-256 d0d4351e3ad5fc24683f3d0462b0429678e8338649df347f26324ef897eb1b43

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlalchemybulk-0.1.7-py3-none-any.whl:

Publisher: update_pypi_package.yml on sudonorm/sqlalchemy-bulk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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