Any recommendations for an easy-to-use pg Python library? AFAICT psycopg2 requires users to do:
import psycopg2
from psycopg2 import Error
try:
# Connect to an existing database
connection = psycopg2.connect(user="postgres",
password="pynative@#29",
host="127.0.0.1",
port="5432",
database="postgres_db")
cursor = connection.cursor()
cursor.execute("SELECT version();")
record = cursor.fetchone()
Having to manage the connection object myself is meh.I'd like to be able to do:
import pg_interface
pg = pg_interface.init(db_config)
pg.command(some_sql_string, some_params)
or even import pg_interface
pg_interface.command(some_sql_string, some_params, db_config)
and have the lib deal with initialising and managing any connection pools/objects.