Metadata-Version: 2.1
Name: database_wrapper_pgsql
Version: 0.1.28
Summary: database_wrapper for PostgreSQL database
Author-email: Gints Murans <gm@gm.lv>
License: GNU General Public License v3.0 (GPL-3.0)
Project-URL: Homepage, https://github.com/gintsmurans/py_database_wrapper
Project-URL: Documentation, https://github.com/gintsmurans/py_database_wrapper
Project-URL: Changes, https://github.com/gintsmurans/py_database_wrapper
Project-URL: Code, https://github.com/gintsmurans/py_database_wrapper
Project-URL: Issue Tracker, https://github.com/gintsmurans/py_database_wrapper/issues
Project-URL: Download, https://pypi.org/project/database_wrapper/
Keywords: database,wrapper,python,postgresql,pgsql
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
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 :: 3.13
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Database
Classifier: Topic :: Database :: Front-Ends
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: database-wrapper ==0.1.28
Requires-Dist: psycopg[binary] >=3.2.0
Requires-Dist: psycopg[pool] >=3.2.0

# database_wrapper

_Part of the `database_wrapper` package._

This python package is a database wrapper for [PostgreSQL](https://www.postgresql.org/) (also called pgsql) databases.

## Installation

```bash
pip install database_wrapper[pgsql]
```

## Usage

```python
from database_wrapper_pgsql import AsyncPgSQLWithPooling, DBWrapperPgSQL

db = MySQL({
    "hostname": "localhost",
    "port": 3306,
    "username": "root",
    "password": "your_password",
    "database": "my_database"
})
db.open()
dbWrapper = DBWrapperMySQL(db=db)

# Simple query
aModel = MyModel()
res = await dbWrapper.getByKey(
    aModel,
    "id",
    3005,
)
if res:
    print(f"getByKey: {res.toDict()}")
else:
    print("No results")

# Raw query
res = await dbWrapper.getAll(
    aModel,
    """
        SELECT t1.*, t2.name AS other_name
        FROM my_table AS t1
        LEFT JOIN other_table AS t2 ON t1.other_id = t2.id
    """
)
async for record in res:
    print(f"getAll: {record.toDict()}")
else:
    print("No results")

db.close()
```
