Skip to main content

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

comapsmarthome-postgres-client-0.1.3.tar.gz (1.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file comapsmarthome-postgres-client-0.1.3.tar.gz.

File metadata

  • Download URL: comapsmarthome-postgres-client-0.1.3.tar.gz
  • Upload date:
  • Size: 1.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for comapsmarthome-postgres-client-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d91bef3020f5c8207f7ee52d9022e25d5e95ce01f066125d18c5da7027dfc302
MD5 6e185eb040338313f894e5bf781ee468
BLAKE2b-256 00c51f0ab7c0129b02c8e27453f989fbf09fe819574bdc7531bfab2d8371e088

See more details on using hashes here.

File details

Details for the file comapsmarthome_postgres_client-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: comapsmarthome_postgres_client-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 1.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for comapsmarthome_postgres_client-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cd688af5985fb3dba3a8ebd5ef583419e4523cf0ea6f04b272b7bf659f692007
MD5 9a08534a446603dd54f9da21433dbd54
BLAKE2b-256 a050b539602d1e68491a613578496f8ff1c58f05ac156fd2f252a322341fad24

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page