Wrapper around psycopg2 to simplify the process of connecting to a PostgreSQL database and executing queries.
Project description
Simple PostgreSQL Wrapper for Python
This project contains a Python script (simplepgsql.py) that provides a simple interface for interacting with a PostgreSQL database using psycopg2 library.
Getting Started
Install via PIP
pip install simplepgsql
Dependent Libraries
- Python 3.6+
- psycopg2 Python library
- Pandas
Usage
from simplepgsql Import DBConnect
conn_params = {
"host": config['DB']['DB_HOST'],
"database": config['DB']['DB_NAME'],
"user": config['DB']['DB_USER'].strip(),
"password": config['DB']['DB_PASSWORD'].strip(),
"port": config['DB']['DB_PORT'],
}
_query_params = {
"schema": "public",
"table_name": "film_list",
"columns": ["category", "price"],
"aggregate": {
"price": "SUM"
},
"conditions": {
"length": (60, ">")
},
"order_by": ("price", "DESC"),
"group_by": ["category", "price"],
"limit": 10,
}
results = pgsql.read(**_query_params)
print(results)
Output
category price.sum
0 New 109.78
1 Travel 109.78
2 Family 74.85
3 Games 129.74
4 Documentary 69.86
5 Animation 74.85
6 Sports 119.76
7 Comedy 94.81
8 Horror 89.82
9 Foreign 99.80
License
This project is licensed under the GNU GPL v3 License.
Project details
Release history Release notifications | RSS feed
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 simplepgsql-0.1.13.tar.gz.
File metadata
- Download URL: simplepgsql-0.1.13.tar.gz
- Upload date:
- Size: 42.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e0124dcfaa8c14af698684ef24b638c954246daf91e8a22e09852d7f2c2a917
|
|
| MD5 |
7b742c3a31056d412b64924ae31bfcd3
|
|
| BLAKE2b-256 |
19e25be0e9fa3da4ae40a78385532082bca1163582969b30fe990005b2ae85fb
|
File details
Details for the file simplepgsql-0.1.13-py2.py3-none-any.whl.
File metadata
- Download URL: simplepgsql-0.1.13-py2.py3-none-any.whl
- Upload date:
- Size: 45.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc337485f6d90134e67c9827c73208c46e0673afb4a31160124eeed780f7baac
|
|
| MD5 |
b705944ca8afd028076544a024c225f0
|
|
| BLAKE2b-256 |
5e50ec49e233e678b8f6d865e1facdd3c3fad99b69f5ea430bb8e5fcf6fda602
|