database-wrapper-pgsql 0.1.44__tar.gz → 0.1.73__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (19) hide show
  1. {database_wrapper_pgsql-0.1.44 → database_wrapper_pgsql-0.1.73}/PKG-INFO +32 -29
  2. database_wrapper_pgsql-0.1.73/README.md +58 -0
  3. {database_wrapper_pgsql-0.1.44 → database_wrapper_pgsql-0.1.73}/database_wrapper_pgsql/__init__.py +7 -0
  4. database_wrapper_pgsql-0.1.73/database_wrapper_pgsql/connector.py +811 -0
  5. database_wrapper_pgsql-0.1.73/database_wrapper_pgsql/db_wrapper_pgsql.py +71 -0
  6. database_wrapper_pgsql-0.1.73/database_wrapper_pgsql/db_wrapper_pgsql_async.py +73 -0
  7. {database_wrapper_pgsql-0.1.44 → database_wrapper_pgsql-0.1.73}/database_wrapper_pgsql/db_wrapper_pgsql_mixin.py +2 -23
  8. {database_wrapper_pgsql-0.1.44 → database_wrapper_pgsql-0.1.73}/database_wrapper_pgsql.egg-info/PKG-INFO +32 -29
  9. {database_wrapper_pgsql-0.1.44 → database_wrapper_pgsql-0.1.73}/database_wrapper_pgsql.egg-info/requires.txt +1 -1
  10. {database_wrapper_pgsql-0.1.44 → database_wrapper_pgsql-0.1.73}/pyproject.toml +2 -2
  11. database_wrapper_pgsql-0.1.44/README.md +0 -55
  12. database_wrapper_pgsql-0.1.44/database_wrapper_pgsql/connector.py +0 -323
  13. database_wrapper_pgsql-0.1.44/database_wrapper_pgsql/db_wrapper_pgsql.py +0 -134
  14. database_wrapper_pgsql-0.1.44/database_wrapper_pgsql/db_wrapper_pgsql_async.py +0 -147
  15. {database_wrapper_pgsql-0.1.44 → database_wrapper_pgsql-0.1.73}/database_wrapper_pgsql/py.typed +0 -0
  16. {database_wrapper_pgsql-0.1.44 → database_wrapper_pgsql-0.1.73}/database_wrapper_pgsql.egg-info/SOURCES.txt +0 -0
  17. {database_wrapper_pgsql-0.1.44 → database_wrapper_pgsql-0.1.73}/database_wrapper_pgsql.egg-info/dependency_links.txt +0 -0
  18. {database_wrapper_pgsql-0.1.44 → database_wrapper_pgsql-0.1.73}/database_wrapper_pgsql.egg-info/top_level.txt +0 -0
  19. {database_wrapper_pgsql-0.1.44 → database_wrapper_pgsql-0.1.73}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: database_wrapper_pgsql
3
- Version: 0.1.44
3
+ Version: 0.1.73
4
4
  Summary: database_wrapper for PostgreSQL database
5
5
  Author-email: Gints Murans <gm@gm.lv>
6
6
  License: GNU General Public License v3.0 (GPL-3.0)
@@ -32,7 +32,7 @@ Classifier: Topic :: Software Development
32
32
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
33
33
  Requires-Python: >=3.8
34
34
  Description-Content-Type: text/markdown
35
- Requires-Dist: database_wrapper==0.1.44
35
+ Requires-Dist: database_wrapper==0.1.73
36
36
  Requires-Dist: psycopg[binary]>=3.2.0
37
37
  Requires-Dist: psycopg[pool]>=3.2.0
38
38
 
@@ -60,34 +60,37 @@ db = PgSQLWithPoolingAsync({
60
60
  "password": "your_password",
61
61
  "database": "my_database"
62
62
  })
63
- db.open()
64
- dbWrapper = DBWrapperPgSQLAsync(db=db)
63
+ await db.openPool()
64
+ try:
65
+ async with db as (dbConn, dbCursor):
66
+ dbWrapper = DBWrapperPgSQLAsync(dbCursor=dbCursor)
65
67
 
66
- # Simple query
67
- aModel = MyModel()
68
- res = await dbWrapper.getByKey(
69
- aModel,
70
- "id",
71
- 3005,
72
- )
73
- if res:
74
- print(f"getByKey: {res.toDict()}")
75
- else:
76
- print("No results")
68
+ # Simple query
69
+ aModel = MyModel()
70
+ res = await dbWrapper.getByKey(
71
+ aModel,
72
+ "id",
73
+ 3005,
74
+ )
75
+ if res:
76
+ print(f"getByKey: {res.toDict()}")
77
+ else:
78
+ print("No results")
77
79
 
78
- # Raw query
79
- res = await dbWrapper.getAll(
80
- aModel,
81
- customQuery="""
82
- SELECT t1.*, t2.name AS other_name
83
- FROM my_table AS t1
84
- LEFT JOIN other_table AS t2 ON t1.other_id = t2.id
85
- """
86
- )
87
- async for record in res:
88
- print(f"getAll: {record.toDict()}")
89
- else:
90
- print("No results")
80
+ # Raw query
81
+ res = await dbWrapper.getAll(
82
+ aModel,
83
+ customQuery="""
84
+ SELECT t1.*, t2.name AS other_name
85
+ FROM my_table AS t1
86
+ LEFT JOIN other_table AS t2 ON t1.other_id = t2.id
87
+ """
88
+ )
89
+ async for record in res:
90
+ print(f"getAll: {record.toDict()}")
91
+ else:
92
+ print("No results")
91
93
 
92
- db.close()
94
+ finally:
95
+ await db.openPool()
93
96
  ```
@@ -0,0 +1,58 @@
1
+ # database_wrapper_pgsql
2
+
3
+ _Part of the `database_wrapper` package._
4
+
5
+ This python package is a database wrapper for [PostgreSQL](https://www.postgresql.org/) (also called pgsql) database.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install database_wrapper[pgsql]
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```python
16
+ from database_wrapper_pgsql import PgSQLWithPoolingAsync, DBWrapperPgSQLAsync
17
+
18
+ db = PgSQLWithPoolingAsync({
19
+ "hostname": "localhost",
20
+ "port": 3306,
21
+ "username": "root",
22
+ "password": "your_password",
23
+ "database": "my_database"
24
+ })
25
+ await db.openPool()
26
+ try:
27
+ async with db as (dbConn, dbCursor):
28
+ dbWrapper = DBWrapperPgSQLAsync(dbCursor=dbCursor)
29
+
30
+ # Simple query
31
+ aModel = MyModel()
32
+ res = await dbWrapper.getByKey(
33
+ aModel,
34
+ "id",
35
+ 3005,
36
+ )
37
+ if res:
38
+ print(f"getByKey: {res.toDict()}")
39
+ else:
40
+ print("No results")
41
+
42
+ # Raw query
43
+ res = await dbWrapper.getAll(
44
+ aModel,
45
+ customQuery="""
46
+ SELECT t1.*, t2.name AS other_name
47
+ FROM my_table AS t1
48
+ LEFT JOIN other_table AS t2 ON t1.other_id = t2.id
49
+ """
50
+ )
51
+ async for record in res:
52
+ print(f"getAll: {record.toDict()}")
53
+ else:
54
+ print("No results")
55
+
56
+ finally:
57
+ await db.openPool()
58
+ ```
@@ -11,9 +11,14 @@ import logging
11
11
  from .db_wrapper_pgsql import DBWrapperPgSQL
12
12
  from .db_wrapper_pgsql_async import DBWrapperPgSQLAsync
13
13
  from .connector import (
14
+ # Basics
14
15
  PgConfig,
16
+ # Connectors
15
17
  PgSQL,
18
+ PgSQLAsync,
19
+ PgSQLWithPooling,
16
20
  PgSQLWithPoolingAsync,
21
+ # Connection and Cursor types
17
22
  PgConnectionType,
18
23
  PgCursorType,
19
24
  PgConnectionTypeAsync,
@@ -32,6 +37,8 @@ __all__ = [
32
37
  "DBWrapperPgSQLAsync",
33
38
  # Connectors
34
39
  "PgSQL",
40
+ "PgSQLAsync",
41
+ "PgSQLWithPooling",
35
42
  "PgSQLWithPoolingAsync",
36
43
  # Connection and Cursor types
37
44
  "PgConnectionType",