this library allow to simplify the basic operation in postgres databases like select, insert, update, delete and upsert
Project description
Provides basic postgres functions for databases request.
select:
def get_my_data():
def _(cursor):
cursor.execute(f"select data from database")
return cursor.fetchone()
result = select(_)
return result.get('data') if result else None
insert:
def insert_my_data():
data = {
'data_1': data_1,
'data_2': data_2
}
insert(TABLE_NAME, data)
update: the primary key can be a string for array who have only one primary key but if it's a tuple, you can put a table of string : ['first_primay_key', 'second_primay_key']
def update_my_data():
data = {
'data_1': data_1,
'data_2': data_2
}
update(TABLE_NAME, 'my_primary_key', data)
upsert: Upsert is a function who insert if the data doesn't exist. And update if the data can be updated. the primary key can be a string for array who have only one primary key but if it's a tuple, you can put a table of string : ['first_primay_key', 'second_primay_key']
def upsert_my_data():
data = {
'data_1': data_1,
'data_2': data_2
}
upsert(TABLE_NAME, 'my_primary_key', data)
delete:
def delete_my_data():
delete(TABLE_NAME, primary_key, data_id)
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
Hashes for comapsmarthome-postgres-client-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39a447fcc1fa90ec0af67177d0b2b33892e3d5e64052b5a0cdd8f1395d15f15e |
|
MD5 | 6675eeb38ab6727a51770927b53ee1a3 |
|
BLAKE2b-256 | 02e05ba63b7137a30a3d228590b29e3cd52af6923ce5c3a08cd83411c632ea05 |
Hashes for comapsmarthome_postgres_client-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 913c0a761b675b7182cd0e32b5d86520132738db1cf2e1b8a22120e8e1a0f630 |
|
MD5 | 23fcfccbd3421b2c210edb9241aa7184 |
|
BLAKE2b-256 | 15ee57a26d676bdd89e23d02f5dbcd78a450002363e89b60f0ee334dad82f998 |