-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Docs update - Changed abstractions sructure for psql engine
- Loading branch information
Showing
11 changed files
with
131 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Engine | ||
|
||
Engine is abstract class or module to isolate sqllex code from unnecessary dependencies. | ||
Engine have to be corresponding to AbstractEngine class. | ||
You can find the current abstraction for engine in `sqllex/core/entities/abc/{engine.py | connection.py}` | ||
|
||
## PostgreSQLx engine | ||
Current abstraction for PostgreSQLx located in `sqllex/core/entities/postgresqlx/engine.py` | ||
|
||
> Recommend to use psycopg2 (from the box) | ||
```shell | ||
pip install psycopg2 | ||
``` | ||
|
||
```python | ||
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 | ||
) | ||
``` | ||
|
||
Read more in [./about-postgresqlx.md](about-postgresqlx.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# AbstractTable | ||
# Table | ||
|
||
```python | ||
class AbstractTable(ABC): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
# "\033[0m" | ||
# "\n") | ||
|
||
__version__ = '0.3.0b1' | ||
__version__ = '0.3.0b2' | ||
|
||
__all__ = [ | ||
# classes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,9 @@ | ||
from abc import ABC, abstractmethod | ||
from sqllex.core.entities.abc.connection import AbstractConnection | ||
|
||
|
||
class AbstractEngine(ABC): | ||
|
||
class AbstractExtensions(ABC): | ||
@abstractmethod | ||
def new_type(self, *args, **kwargs): | ||
pass | ||
|
||
@abstractmethod | ||
def register_type(self, *args, **kwargs): | ||
pass | ||
|
||
@property | ||
@abstractmethod | ||
def extensions(self): | ||
pass | ||
|
||
@abstractmethod | ||
def connect( | ||
self, | ||
dbname=None, | ||
user=None, | ||
password=None, | ||
host=None, | ||
port=None, | ||
**kwargs | ||
): | ||
def connect(self) -> AbstractConnection: | ||
pass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from sqllex.core.entities.abc.engine import AbstractEngine | ||
from sqllex.core.entities.abc.engine import AbstractConnection | ||
|
||
|
||
class PostgreSQLxConnection(AbstractConnection): | ||
class PostgreSQLxCursor: | ||
|
||
def execute(self, script, values=None): | ||
pass | ||
|
||
def executemany(self, script, values=None): | ||
pass | ||
|
||
def fetchall(self): | ||
pass | ||
|
||
def cursor(self) -> PostgreSQLxCursor: | ||
pass | ||
|
||
def commit(self): | ||
pass | ||
|
||
def close(self): | ||
pass | ||
|
||
|
||
class PostgreSQLxExtensions: | ||
def new_type(self, *args, **kwargs): | ||
pass | ||
|
||
def register_type(self, *args, **kwargs): | ||
pass | ||
|
||
|
||
class PostgreSQLxEngine(AbstractEngine): | ||
@property | ||
def extensions(self) -> PostgreSQLxExtensions: | ||
return PostgreSQLxExtensions() | ||
|
||
def connect( | ||
self, | ||
dbname=None, | ||
user=None, | ||
password=None, | ||
host=None, | ||
port=None, | ||
**kwargs | ||
) -> PostgreSQLxConnection: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters