Skip to content

Commit cb58415

Browse files
committed
updates for pypi
1 parent dbc4c0b commit cb58415

File tree

12 files changed

+128
-2
lines changed

12 files changed

+128
-2
lines changed

.idea/workspace.xml

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Easy Postgres Engine
2+
3+
The aim of this package is to provide an easier way to interface with Postgres databases.
4+
5+
It contains a single _PostgresEngine_ class that extracts some typical features that a database connector would need. Generating connections/cursors, and wrapping select/update queries in a retry decorator.
6+
7+
You can use it like this;
8+
```
9+
from easy_postgres_engine import PostgresEngine
10+
11+
engine = PostgresEngine(
12+
databaseName=DATABASE_NAME,
13+
user=USER,
14+
password=PASSWORD,
15+
host=HOST, # default "localhost"
16+
port=PORT # default 5432
17+
)
18+
19+
results = engine.run_select_query(
20+
query="SELECT * FROM tbl_example WHERE example_variable = %(exampleVariable)s",
21+
parameters={'exampleVariable': 100}
22+
)
23+
```
24+
25+
Or by subclassing and defining some commonly used queries;
26+
27+
```
28+
from easy_postgres_engine import PostgresEngine
29+
30+
class ExampleEngine(PostgresEngine):
31+
32+
def __init__(user, password, databaseName, host, port):
33+
super().__init__(user=user, password=password, databaseName=databaseName, host=host, port=port)
34+
35+
def example_query(exampleVariable):
36+
return self.run_select_query(
37+
query="SELECT id FROM tbl_example WHERE example_variable = %(exampleVariable)s,
38+
parameters={'exampleVariable': exampleVariable}
39+
)
40+
```

__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

easy_postgres_engine/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .postgres_engine import PostgresEngine
209 Bytes
Binary file not shown.
3.97 KB
Binary file not shown.
1.06 KB
Binary file not shown.

postgres_engine.py renamed to easy_postgres_engine/postgres_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import psycopg2
44
import psycopg2.extras
55

6-
from retry_decorator import retry
6+
from .retry_decorator import retry
77

88

99
class PostgresEngine:
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)