postgreslite 0.1.2__tar.gz → 0.1.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: postgreslite
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Python SQLite combined with syntax compared to asyncpg progject.
5
5
  Author: AlexFlipnote
6
6
  License-File: LICENSE
@@ -2,4 +2,4 @@
2
2
  from .handler import *
3
3
  from .pool import *
4
4
 
5
- __version__ = "0.1.2"
5
+ __version__ = "0.1.3"
@@ -9,6 +9,11 @@ __all__ = (
9
9
  )
10
10
 
11
11
 
12
+ class CustomCursor(sqlite3.Cursor):
13
+ def __init__(self, *args, **kwargs):
14
+ super().__init__(*args, **kwargs)
15
+
16
+
12
17
  def dict_factory(cursor: sqlite3.Cursor, row: list) -> dict:
13
18
  """ Convert SQLite3 data to dict """
14
19
  d = {}
@@ -41,7 +41,7 @@ class PoolConnection:
41
41
  """ Execute SQL command with args for 'Prepared Statements' """
42
42
  data = self._init_executor(query, *args)
43
43
 
44
- status_word = query.split(" ")[0].strip().upper()
44
+ status_word = query.strip().split(" ")[0].upper()
45
45
  status_code = data.rowcount if data.rowcount > 0 else 0
46
46
  if status_word == "SELECT":
47
47
  status_code = len(data.fetchall())
@@ -72,10 +72,12 @@ class AsyncPoolConnection(PoolConnection):
72
72
  async def _queue_manager(self):
73
73
  while True:
74
74
  query, args, future = await self._queue.get()
75
+
75
76
  try:
76
77
  await self._background_task(query, *args, future=future)
77
- except Exception as e:
78
- print(f"PostgresLite error: {e}")
78
+ except Exception:
79
+ pass
80
+
79
81
  self._queue.task_done()
80
82
 
81
83
  async def _background_task(self, query: str, *args: Any, future: asyncio.Future) -> None:
@@ -88,6 +90,7 @@ class AsyncPoolConnection(PoolConnection):
88
90
  query,
89
91
  prep.prepared
90
92
  )
93
+
91
94
  future.set_result(cursor)
92
95
  except Exception as e:
93
96
  future.set_exception(e)
@@ -96,7 +99,11 @@ class AsyncPoolConnection(PoolConnection):
96
99
  """ Initialize SQL executor with args for 'Prepared Statements' """
97
100
  future = self.loop.create_future()
98
101
  await self._queue.put((query, args, future))
99
- return await future
102
+
103
+ try:
104
+ return await future
105
+ except Exception:
106
+ raise future.exception()
100
107
 
101
108
  @property
102
109
  def queue_size(self) -> int:
@@ -111,9 +118,12 @@ class AsyncPoolConnection(PoolConnection):
111
118
 
112
119
  async def execute(self, query: str, *args: Any) -> str:
113
120
  """ Execute SQL command with args for 'Prepared Statements' """
114
- data = await self._init_executor(query, *args)
121
+ try:
122
+ data = await self._init_executor(query, *args)
123
+ except Exception as e:
124
+ raise e
115
125
 
116
- status_word = query.split(" ")[0].strip().upper()
126
+ status_word = query.strip().split(" ")[0].upper()
117
127
  status_code = data.rowcount if data.rowcount > 0 else 0
118
128
  if status_word == "SELECT":
119
129
  status_code = len(data.fetchall())
@@ -122,10 +132,18 @@ class AsyncPoolConnection(PoolConnection):
122
132
 
123
133
  async def fetch(self, query: str, *args: Any) -> list:
124
134
  """ Fetch DB data with args for 'Prepared Statements' """
125
- data = await self._init_executor(query, *args)
135
+ try:
136
+ data = await self._init_executor(query, *args)
137
+ except Exception as e:
138
+ raise e
139
+
126
140
  return data.fetchall()
127
141
 
128
142
  async def fetchrow(self, query: str, *args: Any) -> dict:
129
143
  """ Fetch DB row (one row only) with args for 'Prepared Statements' """
130
- data = await self._init_executor(query, *args)
144
+ try:
145
+ data = await self._init_executor(query, *args)
146
+ except Exception as e:
147
+ raise e
148
+
131
149
  return data.fetchone()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: postgreslite
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Python SQLite combined with syntax compared to asyncpg progject.
5
5
  Author: AlexFlipnote
6
6
  License-File: LICENSE
File without changes
File without changes
File without changes
File without changes