postgreslite 0.1.1__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.1
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.1"
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 = {}
@@ -19,8 +19,6 @@ class SQLStatements:
19
19
  """ Prepare statements for SQLite with *args provided from earlier """
20
20
  arg_len = len(self._args)
21
21
 
22
- print(self._args)
23
-
24
22
  if arg_len <= 0:
25
23
  return ()
26
24
  return self._args
@@ -43,7 +41,7 @@ class PoolConnection:
43
41
  """ Execute SQL command with args for 'Prepared Statements' """
44
42
  data = self._init_executor(query, *args)
45
43
 
46
- status_word = query.split(" ")[0].strip().upper()
44
+ status_word = query.strip().split(" ")[0].upper()
47
45
  status_code = data.rowcount if data.rowcount > 0 else 0
48
46
  if status_word == "SELECT":
49
47
  status_code = len(data.fetchall())
@@ -74,10 +72,12 @@ class AsyncPoolConnection(PoolConnection):
74
72
  async def _queue_manager(self):
75
73
  while True:
76
74
  query, args, future = await self._queue.get()
75
+
77
76
  try:
78
77
  await self._background_task(query, *args, future=future)
79
- except Exception as e:
80
- print(e)
78
+ except Exception:
79
+ pass
80
+
81
81
  self._queue.task_done()
82
82
 
83
83
  async def _background_task(self, query: str, *args: Any, future: asyncio.Future) -> None:
@@ -90,6 +90,7 @@ class AsyncPoolConnection(PoolConnection):
90
90
  query,
91
91
  prep.prepared
92
92
  )
93
+
93
94
  future.set_result(cursor)
94
95
  except Exception as e:
95
96
  future.set_exception(e)
@@ -98,7 +99,11 @@ class AsyncPoolConnection(PoolConnection):
98
99
  """ Initialize SQL executor with args for 'Prepared Statements' """
99
100
  future = self.loop.create_future()
100
101
  await self._queue.put((query, args, future))
101
- return await future
102
+
103
+ try:
104
+ return await future
105
+ except Exception:
106
+ raise future.exception()
102
107
 
103
108
  @property
104
109
  def queue_size(self) -> int:
@@ -113,9 +118,12 @@ class AsyncPoolConnection(PoolConnection):
113
118
 
114
119
  async def execute(self, query: str, *args: Any) -> str:
115
120
  """ Execute SQL command with args for 'Prepared Statements' """
116
- 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
117
125
 
118
- status_word = query.split(" ")[0].strip().upper()
126
+ status_word = query.strip().split(" ")[0].upper()
119
127
  status_code = data.rowcount if data.rowcount > 0 else 0
120
128
  if status_word == "SELECT":
121
129
  status_code = len(data.fetchall())
@@ -124,10 +132,18 @@ class AsyncPoolConnection(PoolConnection):
124
132
 
125
133
  async def fetch(self, query: str, *args: Any) -> list:
126
134
  """ Fetch DB data with args for 'Prepared Statements' """
127
- 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
+
128
140
  return data.fetchall()
129
141
 
130
142
  async def fetchrow(self, query: str, *args: Any) -> dict:
131
143
  """ Fetch DB row (one row only) with args for 'Prepared Statements' """
132
- 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
+
133
149
  return data.fetchone()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: postgreslite
3
- Version: 0.1.1
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