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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea9296e863a167afbb95d1184db97ca2951d2bd4812fab0c64679a2158d1fbb3
|
|
| MD5 |
d258b85234c7c6971b93c78319fc6432
|
|
| BLAKE2b-256 |
844a08e5070a327c2102124d46c631ea34d48c4ed92fd4e4fd35c1823d96b560
|
Provenance
The following attestation bundles were made for sqlalchemybulk-0.1.5.tar.gz:
Publisher:
update_pypi_package.yml on sudonorm/sqlalchemy-bulk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlalchemybulk-0.1.5.tar.gz -
Subject digest:
ea9296e863a167afbb95d1184db97ca2951d2bd4812fab0c64679a2158d1fbb3 - Sigstore transparency entry: 170090663
- Sigstore integration time:
-
Permalink:
sudonorm/sqlalchemy-bulk@9467d40d3390128ec084945aed7a3fa9e3ec199b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sudonorm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
update_pypi_package.yml@9467d40d3390128ec084945aed7a3fa9e3ec199b -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8762f3b34a4b6ff26fba46c7df31051f1f99973d9357dca4faf91f3e436794d
|
|
| MD5 |
0ae548b111d937e3f8ef0c5e08d9d851
|
|
| BLAKE2b-256 |
5e1e9cbb7c65b0758596107bcf19613b0a103551ceaea2cd8d8abf20576b55d2
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlalchemybulk-0.1.5-py3-none-any.whl -
Subject digest:
a8762f3b34a4b6ff26fba46c7df31051f1f99973d9357dca4faf91f3e436794d - Sigstore transparency entry: 170090665
- Sigstore integration time:
-
Permalink:
sudonorm/sqlalchemy-bulk@9467d40d3390128ec084945aed7a3fa9e3ec199b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sudonorm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
update_pypi_package.yml@9467d40d3390128ec084945aed7a3fa9e3ec199b -
Trigger Event:
push
-
Statement type: