PostgreSQLx

Main class to interact with PostgreSQL databases, belongs to the sqllex-databases family, child of AbstractDatabase. Postgres database need engine, we recommend to use psycopg2, just import this lib and give it to Database class constructor. You can read more about engines here.

import psycopg2
import sqllex as sx


db = sx.PostgreSQLx(
    engine=psycopg2,        # Postgres engine
    dbname="test_sqllex",   # database name
    user="postgres",        # username
    password="admin",       # user's password
    host="127.0.0.1",       # psql host address 
    port="5432",            # connection port
    
    # Optional parameters
    template={
        'users': {
            'id': [sx.INTEGER, sx.AUTOINCREMENT],
            'name': sx.TEXT
        }
    },
    
    # Create connection to database with database class object initialisation
    init_connection=True
)

PostgreSQL now is only partially support. It has the same api interface as SQLite3x so feel free to use documentation of it for PostgreSQLx. Just replace SQLite3x at PostgreSQLx.

PostgreSQLx Public Methods

Properties

    * - available only for this specific database-class

Back to home