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

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqlalchemybulk-0.1.5.tar.gz
  • Upload date:
  • Size: 17.2 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.5.tar.gz
Algorithm Hash digest
SHA256 ea9296e863a167afbb95d1184db97ca2951d2bd4812fab0c64679a2158d1fbb3
MD5 d258b85234c7c6971b93c78319fc6432
BLAKE2b-256 844a08e5070a327c2102124d46c631ea34d48c4ed92fd4e4fd35c1823d96b560

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sqlalchemybulk-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a8762f3b34a4b6ff26fba46c7df31051f1f99973d9357dca4faf91f3e436794d
MD5 0ae548b111d937e3f8ef0c5e08d9d851
BLAKE2b-256 5e1e9cbb7c65b0758596107bcf19613b0a103551ceaea2cd8d8abf20576b55d2

See more details on using hashes here.

Provenance

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