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.6.tar.gz (17.3 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.6-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqlalchemybulk-0.1.6.tar.gz
  • Upload date:
  • Size: 17.3 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.6.tar.gz
Algorithm Hash digest
SHA256 e0e40620dd60fdd1481542d5a16ee5faa2c7f698b7053893de9ccd9c61b51a8f
MD5 b6898040d58568b4271cefa7abf6f362
BLAKE2b-256 5a6bd60ab3f41f9a6c7b902e4c4c301bea51a759a7f29b12a49e90ab3dc3c416

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlalchemybulk-0.1.6.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.6-py3-none-any.whl.

File metadata

  • Download URL: sqlalchemybulk-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 18.6 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 937836f0bc0f3a0c98f803cda127524c41912d14e8ed8223a1cc394909b374a8
MD5 4a9137754615833ab28cf59e82b21b49
BLAKE2b-256 41456eec9fe9b13fb6dc446c9fb52c04ac8c7c72a5c27bccabb596b924baf1b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlalchemybulk-0.1.6-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