# database_wrapper_pgsql
_Part of the `database_wrapper` package._
This python package is a database wrapper for [PostgreSQL](https://www.postgresql.org/) (also called pgsql) database.
## Installation
```bash
pip install database_wrapper[pgsql]
```
## Usage
```python
from database_wrapper_pgsql import PgSQLWithPoolingAsync, DBWrapperPgSQLAsync
db = PgSQLWithPoolingAsync({
"hostname": "localhost",
"port": 3306,
"username": "root",
"password": "your_password",
"database": "my_database"
})
await db.openPool()
try:
async with db as (dbConn, dbCursor):
dbWrapper = DBWrapperPgSQLAsync(dbCursor=dbCursor)
# 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,
customQuery="""
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")
finally:
await db.openPool()
```
Raw data
{
"_id": null,
"home_page": null,
"name": "database-wrapper-pgsql",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "database, wrapper, python, postgresql, pgsql",
"author": null,
"author_email": "Gints Murans <gm@gm.lv>",
"download_url": "https://files.pythonhosted.org/packages/8e/c6/fef696ff2edaa63e70ba2f27b31ba791eb1e1385087763d6d6bce54ade4b/database_wrapper_pgsql-0.1.73.tar.gz",
"platform": null,
"description": "# database_wrapper_pgsql\n\n_Part of the `database_wrapper` package._\n\nThis python package is a database wrapper for [PostgreSQL](https://www.postgresql.org/) (also called pgsql) database.\n\n## Installation\n\n```bash\npip install database_wrapper[pgsql]\n```\n\n## Usage\n\n```python\nfrom database_wrapper_pgsql import PgSQLWithPoolingAsync, DBWrapperPgSQLAsync\n\ndb = PgSQLWithPoolingAsync({\n \"hostname\": \"localhost\",\n \"port\": 3306,\n \"username\": \"root\",\n \"password\": \"your_password\",\n \"database\": \"my_database\"\n})\nawait db.openPool()\ntry:\n async with db as (dbConn, dbCursor):\n dbWrapper = DBWrapperPgSQLAsync(dbCursor=dbCursor)\n\n # Simple query\n aModel = MyModel()\n res = await dbWrapper.getByKey(\n aModel,\n \"id\",\n 3005,\n )\n if res:\n print(f\"getByKey: {res.toDict()}\")\n else:\n print(\"No results\")\n\n # Raw query\n res = await dbWrapper.getAll(\n aModel,\n customQuery=\"\"\"\n SELECT t1.*, t2.name AS other_name\n FROM my_table AS t1\n LEFT JOIN other_table AS t2 ON t1.other_id = t2.id\n \"\"\"\n )\n async for record in res:\n print(f\"getAll: {record.toDict()}\")\n else:\n print(\"No results\")\n\nfinally:\n await db.openPool()\n```\n",
"bugtrack_url": null,
"license": "GNU General Public License v3.0 (GPL-3.0)",
"summary": "database_wrapper for PostgreSQL database",
"version": "0.1.73",
"project_urls": {
"Changes": "https://github.com/gintsmurans/py_database_wrapper",
"Code": "https://github.com/gintsmurans/py_database_wrapper",
"Documentation": "https://github.com/gintsmurans/py_database_wrapper",
"Download": "https://pypi.org/project/database_wrapper/",
"Homepage": "https://github.com/gintsmurans/py_database_wrapper",
"Issue Tracker": "https://github.com/gintsmurans/py_database_wrapper/issues"
},
"split_keywords": [
"database",
" wrapper",
" python",
" postgresql",
" pgsql"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "358fa0f400f5ada51296e751f185813c766e1f93799216f6250c1b24f0894432",
"md5": "4c6d300e5bbb8a059b9dd4365ac4df12",
"sha256": "0bc813a2a44b7567ec1b9ef15e636d889a365474fd4591e732b81af70fca2320"
},
"downloads": -1,
"filename": "database_wrapper_pgsql-0.1.73-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4c6d300e5bbb8a059b9dd4365ac4df12",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 10069,
"upload_time": "2024-12-22T02:13:03",
"upload_time_iso_8601": "2024-12-22T02:13:03.980600Z",
"url": "https://files.pythonhosted.org/packages/35/8f/a0f400f5ada51296e751f185813c766e1f93799216f6250c1b24f0894432/database_wrapper_pgsql-0.1.73-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8ec6fef696ff2edaa63e70ba2f27b31ba791eb1e1385087763d6d6bce54ade4b",
"md5": "dfecbb8d11059b550c0bcf6cd84ff20c",
"sha256": "68f89783dbf234682bb9c2e007df5a898467a09109d25b2859d1afacecbebdef"
},
"downloads": -1,
"filename": "database_wrapper_pgsql-0.1.73.tar.gz",
"has_sig": false,
"md5_digest": "dfecbb8d11059b550c0bcf6cd84ff20c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 9067,
"upload_time": "2024-12-22T02:13:14",
"upload_time_iso_8601": "2024-12-22T02:13:14.944327Z",
"url": "https://files.pythonhosted.org/packages/8e/c6/fef696ff2edaa63e70ba2f27b31ba791eb1e1385087763d6d6bce54ade4b/database_wrapper_pgsql-0.1.73.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-22 02:13:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gintsmurans",
"github_project": "py_database_wrapper",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "database-wrapper-pgsql"
}