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
.
- add_column
- connect
- create_table
- create_temp_table
- create_temporary_table
- delete
- disconnect
- drop
- execute
- executemany
- executescript
- get_columns
- get_columns_names
- get_table
- insert
- insertmany
- markup
- remove_column
replace- select
- select_all
select_distincttable_info- update
- updatemany
* - available only for this specific database-class