GithubHelp home page GithubHelp logo

pg_python's Introduction

Postgres python

A simple api to read, write, delete and update in a postgres database

Installation : Linux/Mac

$ pip install pg_python

Server Initialization

$ from pg_python.pg_python import *
$ pgs = pg_server(db_name, username, password, host_address)

Schema Definition (Optional)(Not available)

$ schema_map = Schema()
$ pgs.add_schema(db_name, schema_map)

Read operation

Return value is a list of dictionaries. Every dictionary is representative of the row that is fetched. Each dictionary's key is the same as the column name fetched.

$ value_list = read(table_name, keys_to_get_dict, where_kv_dict, limit, order_by, order_type, operator_string)

Parameter information :

  • keys_to_get_dict(a list of column names to fetch)
  • where_kv_dict(a dictionary to specify the 'Where' clause)

Example usage : print pg_python.read("mock_table", ['column2','column3'], {"column_1":'55'})

Resulting query: SELECT column2, column3 FROM mock_table WHERE column1 = %s, ['55']

Sample output: [{'column2': 'column_data_A', 'column3': 'column_data_Z'}, {'column2': 'column_data_P', 'column3': 'column_data_Q'}]

Write operation

$ write(table_name, kv_dict)

Overwrite operation

$ write(table_name, kv_dict)

Update operation

$ update(table, update_kv_map, where_kv_map)

Delete operation

$ delete(table, where_kv_map, single_row)

pg_python's People

Contributors

ingloriousp avatar lakshmi-k05 avatar abhishekpowar avatar bhargav066 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.