Welcome to postgres-helper’s documentation!

About postgres-helper!

What is postgres-helper?

The postgres-helper library is build on top of psycopg2. It will be really helpful for running the basic postgresql query in python.

Installation

pip install postgres-helper

How to use

Examples using this library

#Library import
from pg.pg import Pg

# Initialization of library
pg = Db(dbname='postgres', user='postgres', password='admin', host='localhost', port='5432')

# Get the column names of the specific table
pg.get_columns_name(table='pg_table')

# Get values from specific column of table
pg.get_values_from_column(column='pg_table_col', table='pg_table', schema='public')

# Create schema
pg.create_schema(name='schema_name')

# Create column
pg.create_column(column='col_name', table='pg_table', col_datatype='varchar', schema='public')

# Update column
pg.update_column(column='col_name', value='updated_value', table='pg_table', where_column='where_col', where_value="where_val", schema='public')

# Delete table
pg.delete_table(name='pg_table', schema='public')

# Delete values
pg.delete_values(table_name='pg_table', condition='name=value', schema='public')

Global parameters for most of the functions

The following parameters are the common parameters in most of the functions/methods,

  • schema: If schema is not provided, the function will take the public schema.

Change Log

License

MIT License

Copyright (c) 2020, Geoinformatics Center, Asian Institute of Technology

Copyright (c) 2020, Tek Kshetri

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contribution

postgres-helper is the open source library written in python and contributors are needed to keep this library moving forward. Any kind of contributions are welcome.

Acknowledgements

Created and managed by Tek Bahadur Kshetri for the activites of Geoinformatics Center of Asian Institute of Technology, Thailand.