11# PostgreSQLx
22
33Main class to interact with PostgreSQL databases, belongs to the sqllex-databases family, child of AbstractDatabase.
4+ Postgres database need ` engine ` , we recommend to use psycopg2, just import this lib and give it to Database class constructor.
5+ You can read more [ about engines here] ( ./about-engines.md ) .
46
57``` python
6- # from sqllex import PostgreSQLx, INTEGER, TEXT, AUTOINCREMENT
7- from sqllex.classes import PostgreSQLx
8- from sqllex.constants.sqlite import INTEGER , TEXT , AUTOINCREMENT
8+ import psycopg2
9+ import sqllex as sx
910
1011
11- db = PostgreSQLx(
12- dbname = " sqllextests" , # database name
12+ db = sx.PostgreSQLx(
13+ engine = psycopg2, # Postgres engine
14+ dbname = " test_sqllex" , # database name
1315 user = " postgres" , # username
1416 password = " admin" , # user's password
1517 host = " 127.0.0.1" , # psql host address
@@ -18,17 +20,21 @@ db = PostgreSQLx(
1820 # Optional parameters
1921 template = {
2022 ' users' : {
21- ' id' : [INTEGER , AUTOINCREMENT ],
22- ' name' : TEXT
23+ ' id' : [sx. INTEGER , sx. AUTOINCREMENT ],
24+ ' name' : sx. TEXT
2325 }
2426 },
2527
2628 # Create connection to database with database class object initialisation
2729 init_connection = True
2830)
29-
3031```
3132
33+ PostgreSQL now is only partially support.
34+ It has the same api interface as SQLite3x so feel free to use documentation
35+ of it for PostgreSQLx. Just replace ` SQLite3x ` at ` PostgreSQLx ` .
36+
37+
3238## PostgreSQLx Public Methods
3339
3440- [ add_column] ( database-add_column.md )
0 commit comments