Metadata-Version: 2.2
Name: sqlalchemybulk
Version: 0.1.5
Summary: Perform CRUD operations with SQLAlchemy
Author-email: sudonorm <sudonorm@protonmail.com>
License: MIT License
        
        Copyright (c) 2024 sudonorm
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: repository, https://github.com/sudonorm/sqlalchemy-bulk
Keywords: database,sqlalchemy,upsert,bulk,orm,crud
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Database :: Front-Ends
Requires-Python: >=3.7
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: SQLAlchemy>2.0.0
Requires-Dist: alembic>1.9.0
Requires-Dist: pandas>2.0.0
Requires-Dist: numpy
Requires-Dist: packaging
Requires-Dist: python-dotenv
Provides-Extra: build
Requires-Dist: build; extra == "build"
Requires-Dist: twine; extra == "build"
Provides-Extra: dev
Requires-Dist: black; extra == "dev"
Requires-Dist: bumpver; extra == "dev"
Requires-Dist: isort; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: pytest; extra == "dev"

sqlalchemy-bulk
==================

*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
-----------

.. code:: python

    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 <https://github.com/sudonorm/sqlalchemy-bulk/issues>`_.
