Skip to content

Commit 6068ae5

Browse files
Merge pull request #23 from sqlitecloud/#22-fix-compression-rowset-chunk
#22 fix compression rowset chunk
2 parents ec29aeb + 421e41d commit 6068ae5

19 files changed

+352
-229
lines changed

bandit-baseline.json

Lines changed: 68 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
22
"errors": [],
3-
"generated_at": "2024-06-03T07:52:17Z",
3+
"generated_at": "2024-08-06T12:35:09Z",
44
"metrics": {
55
"_totals": {
66
"CONFIDENCE.HIGH": 0.0,
7-
"CONFIDENCE.LOW": 2.0,
7+
"CONFIDENCE.LOW": 3.0,
88
"CONFIDENCE.MEDIUM": 1.0,
99
"CONFIDENCE.UNDEFINED": 0.0,
1010
"SEVERITY.HIGH": 0.0,
1111
"SEVERITY.LOW": 1.0,
12-
"SEVERITY.MEDIUM": 2.0,
12+
"SEVERITY.MEDIUM": 3.0,
1313
"SEVERITY.UNDEFINED": 0.0,
14-
"loc": 3405,
14+
"loc": 3497,
1515
"nosec": 0
1616
},
1717
"src/setup.py": {
@@ -50,19 +50,19 @@
5050
"loc": 104,
5151
"nosec": 0
5252
},
53-
"src/sqlitecloud/dbapi2.py": {
53+
"src/sqlitecloud/datatypes.py": {
5454
"CONFIDENCE.HIGH": 0.0,
5555
"CONFIDENCE.LOW": 0.0,
56-
"CONFIDENCE.MEDIUM": 0.0,
56+
"CONFIDENCE.MEDIUM": 1.0,
5757
"CONFIDENCE.UNDEFINED": 0.0,
5858
"SEVERITY.HIGH": 0.0,
59-
"SEVERITY.LOW": 0.0,
59+
"SEVERITY.LOW": 1.0,
6060
"SEVERITY.MEDIUM": 0.0,
6161
"SEVERITY.UNDEFINED": 0.0,
62-
"loc": 377,
62+
"loc": 177,
6363
"nosec": 0
6464
},
65-
"src/sqlitecloud/download.py": {
65+
"src/sqlitecloud/dbapi2.py": {
6666
"CONFIDENCE.HIGH": 0.0,
6767
"CONFIDENCE.LOW": 0.0,
6868
"CONFIDENCE.MEDIUM": 0.0,
@@ -71,10 +71,10 @@
7171
"SEVERITY.LOW": 0.0,
7272
"SEVERITY.MEDIUM": 0.0,
7373
"SEVERITY.UNDEFINED": 0.0,
74-
"loc": 32,
74+
"loc": 376,
7575
"nosec": 0
7676
},
77-
"src/sqlitecloud/driver.py": {
77+
"src/sqlitecloud/download.py": {
7878
"CONFIDENCE.HIGH": 0.0,
7979
"CONFIDENCE.LOW": 0.0,
8080
"CONFIDENCE.MEDIUM": 0.0,
@@ -83,10 +83,10 @@
8383
"SEVERITY.LOW": 0.0,
8484
"SEVERITY.MEDIUM": 0.0,
8585
"SEVERITY.UNDEFINED": 0.0,
86-
"loc": 765,
86+
"loc": 32,
8787
"nosec": 0
8888
},
89-
"src/sqlitecloud/pubsub.py": {
89+
"src/sqlitecloud/driver.py": {
9090
"CONFIDENCE.HIGH": 0.0,
9191
"CONFIDENCE.LOW": 0.0,
9292
"CONFIDENCE.MEDIUM": 0.0,
@@ -95,10 +95,10 @@
9595
"SEVERITY.LOW": 0.0,
9696
"SEVERITY.MEDIUM": 0.0,
9797
"SEVERITY.UNDEFINED": 0.0,
98-
"loc": 54,
98+
"loc": 787,
9999
"nosec": 0
100100
},
101-
"src/sqlitecloud/resultset.py": {
101+
"src/sqlitecloud/pubsub.py": {
102102
"CONFIDENCE.HIGH": 0.0,
103103
"CONFIDENCE.LOW": 0.0,
104104
"CONFIDENCE.MEDIUM": 0.0,
@@ -107,19 +107,19 @@
107107
"SEVERITY.LOW": 0.0,
108108
"SEVERITY.MEDIUM": 0.0,
109109
"SEVERITY.UNDEFINED": 0.0,
110-
"loc": 80,
110+
"loc": 56,
111111
"nosec": 0
112112
},
113-
"src/sqlitecloud/types.py": {
113+
"src/sqlitecloud/resultset.py": {
114114
"CONFIDENCE.HIGH": 0.0,
115115
"CONFIDENCE.LOW": 0.0,
116-
"CONFIDENCE.MEDIUM": 1.0,
116+
"CONFIDENCE.MEDIUM": 0.0,
117117
"CONFIDENCE.UNDEFINED": 0.0,
118118
"SEVERITY.HIGH": 0.0,
119-
"SEVERITY.LOW": 1.0,
119+
"SEVERITY.LOW": 0.0,
120120
"SEVERITY.MEDIUM": 0.0,
121121
"SEVERITY.UNDEFINED": 0.0,
122-
"loc": 194,
122+
"loc": 99,
123123
"nosec": 0
124124
},
125125
"src/sqlitecloud/upload.py": {
@@ -172,14 +172,14 @@
172172
},
173173
"src/tests/integration/test_client.py": {
174174
"CONFIDENCE.HIGH": 0.0,
175-
"CONFIDENCE.LOW": 0.0,
175+
"CONFIDENCE.LOW": 1.0,
176176
"CONFIDENCE.MEDIUM": 0.0,
177177
"CONFIDENCE.UNDEFINED": 0.0,
178178
"SEVERITY.HIGH": 0.0,
179179
"SEVERITY.LOW": 0.0,
180-
"SEVERITY.MEDIUM": 0.0,
180+
"SEVERITY.MEDIUM": 1.0,
181181
"SEVERITY.UNDEFINED": 0.0,
182-
"loc": 492,
182+
"loc": 543,
183183
"nosec": 0
184184
},
185185
"src/tests/integration/test_dbapi2.py": {
@@ -239,7 +239,7 @@
239239
"SEVERITY.LOW": 0.0,
240240
"SEVERITY.MEDIUM": 1.0,
241241
"SEVERITY.UNDEFINED": 0.0,
242-
"loc": 118,
242+
"loc": 129,
243243
"nosec": 0
244244
},
245245
"src/tests/integration/test_sqlite3_parity.py": {
@@ -287,7 +287,7 @@
287287
"SEVERITY.LOW": 0.0,
288288
"SEVERITY.MEDIUM": 0.0,
289289
"SEVERITY.UNDEFINED": 0.0,
290-
"loc": 242,
290+
"loc": 241,
291291
"nosec": 0
292292
},
293293
"src/tests/unit/test_driver.py": {
@@ -311,7 +311,7 @@
311311
"SEVERITY.LOW": 0.0,
312312
"SEVERITY.MEDIUM": 0.0,
313313
"SEVERITY.UNDEFINED": 0.0,
314-
"loc": 113,
314+
"loc": 119,
315315
"nosec": 0
316316
},
317317
"src/tests/unit/test_types.py": {
@@ -329,51 +329,66 @@
329329
},
330330
"results": [
331331
{
332-
"code": "107 class SQLiteCloudAccount:\n108 def __init__(\n109 self,\n110 username: Optional[str] = \"\",\n111 password: Optional[str] = \"\",\n112 hostname: str = \"\",\n113 dbname: Optional[str] = \"\",\n114 port: int = SQLITECLOUD_DEFAULT.PORT.value,\n115 apikey: Optional[str] = \"\",\n116 ) -> None:\n117 # User name is required unless connectionstring is provided\n118 self.username = username\n119 # Password is required unless connection string is provided\n120 self.password = password\n121 # Password is hashed\n122 self.password_hashed = False\n123 # API key instead of username and password\n124 self.apikey = apikey\n125 # Name of database to open\n126 self.dbname = dbname\n127 # Like mynode.sqlitecloud.io\n128 self.hostname = hostname\n129 self.port = port\n130 \n",
332+
"code": "87 class SQLiteCloudAccount:\n88 def __init__(\n89 self,\n90 username: Optional[str] = \"\",\n91 password: Optional[str] = \"\",\n92 hostname: str = \"\",\n93 dbname: Optional[str] = \"\",\n94 port: int = SQLITECLOUD_DEFAULT.PORT.value,\n95 apikey: Optional[str] = \"\",\n96 ) -> None:\n97 # User name is required unless connectionstring is provided\n98 self.username = username\n99 # Password is required unless connection string is provided\n100 self.password = password\n101 # Password is hashed\n102 self.password_hashed = False\n103 # API key instead of username and password\n104 self.apikey = apikey\n105 # Name of database to open\n106 self.dbname = dbname\n107 # Like mynode.sqlitecloud.io\n108 self.hostname = hostname\n109 self.port = port\n110 \n",
333333
"col_offset": 4,
334-
"filename": "src/sqlitecloud/types.py",
334+
"filename": "src/sqlitecloud/datatypes.py",
335335
"issue_confidence": "MEDIUM",
336336
"issue_severity": "LOW",
337337
"issue_text": "Possible hardcoded password: ''",
338-
"line_number": 108,
338+
"line_number": 88,
339339
"line_range": [
340+
88,
341+
89,
342+
90,
343+
91,
344+
92,
345+
93,
346+
94,
347+
95,
348+
96,
349+
97,
350+
98,
351+
99,
352+
100,
353+
101,
354+
102,
355+
103,
356+
104,
357+
105,
358+
106,
359+
107,
340360
108,
341-
109,
342-
110,
343-
111,
344-
112,
345-
113,
346-
114,
347-
115,
348-
116,
349-
117,
350-
118,
351-
119,
352-
120,
353-
121,
354-
122,
355-
123,
356-
124,
357-
125,
358-
126,
359-
127,
360-
128,
361-
129
361+
109
362362
],
363363
"more_info": "https://bandit.readthedocs.io/en/latest/plugins/b107_hardcoded_password_default.html",
364364
"test_id": "B107",
365365
"test_name": "hardcoded_password_default"
366366
},
367367
{
368-
"code": "164 client.exec_query(\n165 f\"UPDATE genres SET Name = '{new_name}' WHERE GenreId = 1;\", connection\n166 )\n",
368+
"code": "639 for i in range(nRows):\n640 sql += f\"INSERT INTO TestCompress (name) VALUES ('Test {i}'); \"\n641 \n",
369+
"col_offset": 23,
370+
"filename": "src/tests/integration/test_client.py",
371+
"issue_confidence": "LOW",
372+
"issue_severity": "MEDIUM",
373+
"issue_text": "Possible SQL injection vector through string-based query construction.",
374+
"line_number": 640,
375+
"line_range": [
376+
640
377+
],
378+
"more_info": "https://bandit.readthedocs.io/en/latest/plugins/b608_hardcoded_sql_expressions.html",
379+
"test_id": "B608",
380+
"test_name": "hardcoded_sql_expressions"
381+
},
382+
{
383+
"code": "179 client.exec_query(\n180 f\"UPDATE genres SET Name = '{new_name}' WHERE GenreId = 1;\", connection\n181 )\n",
369384
"col_offset": 12,
370385
"filename": "src/tests/integration/test_pubsub.py",
371386
"issue_confidence": "LOW",
372387
"issue_severity": "MEDIUM",
373388
"issue_text": "Possible SQL injection vector through string-based query construction.",
374-
"line_number": 165,
389+
"line_number": 180,
375390
"line_range": [
376-
165
391+
180
377392
],
378393
"more_info": "https://bandit.readthedocs.io/en/latest/plugins/b608_hardcoded_sql_expressions.html",
379394
"test_id": "B608",

src/sqlitecloud/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
"""
44
from typing import Dict, Optional, Tuple, Union
55

6-
from sqlitecloud.driver import Driver
7-
from sqlitecloud.resultset import SQLiteCloudResultSet
8-
from sqlitecloud.types import (
6+
from sqlitecloud.datatypes import (
97
SQLiteCloudAccount,
108
SQLiteCloudConfig,
119
SQLiteCloudConnect,
1210
SQLiteCloudDataTypes,
1311
SQLiteCloudException,
1412
)
13+
from sqlitecloud.driver import Driver
14+
from sqlitecloud.resultset import SQLiteCloudResultSet
1515

1616

1717
class SQLiteCloudClient:

src/sqlitecloud/types.py renamed to src/sqlitecloud/datatypes.py

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import types
21
from asyncio import AbstractEventLoop
32
from enum import Enum
43
from typing import Any, Callable, Dict, Optional, Union
54
from urllib import parse
65

6+
from .resultset import SQLiteCloudResultSet
7+
78
# Basic types supported by SQLite Cloud APIs
89
SQLiteCloudDataTypes = Union[str, int, bool, Dict[Union[str, int], Any], bytes, None]
910

1011

1112
class SQLITECLOUD_DEFAULT(Enum):
1213
PORT = 8860
13-
TIMEOUT = 12
14+
TIMEOUT = 30
1415
UPLOAD_SIZE = 512 * 1024
1516

1617

@@ -37,14 +38,6 @@ class SQLITECLOUD_ROWSET(Enum):
3738
CHUNKS_END = b"/6 0 0 0 "
3839

3940

40-
class SQLITECLOUD_VALUE_TYPE(Enum):
41-
INTEGER = "INTEGER"
42-
FLOAT = "REAL"
43-
TEXT = "TEXT"
44-
BLOB = "BLOB"
45-
NULL = "NULL"
46-
47-
4841
class SQLITECLOUD_INTERNAL_ERRCODE(Enum):
4942
"""
5043
Clients error codes.
@@ -68,19 +61,6 @@ class SQLITECLOUD_ERRCODE(Enum):
6861
RAFT = 10006
6962

7063

71-
class SQLITECLOUD_RESULT_TYPE(Enum):
72-
RESULT_OK = 0
73-
RESULT_ERROR = 1
74-
RESULT_STRING = 2
75-
RESULT_INTEGER = 3
76-
RESULT_FLOAT = 4
77-
RESULT_ROWSET = 5
78-
RESULT_ARRAY = 6
79-
RESULT_NONE = 7
80-
RESULT_JSON = 8
81-
RESULT_BLOB = 9
82-
83-
8464
class SQLITECLOUD_PUBSUB_SUBJECT(Enum):
8565
"""
8666
Subjects that can be subscribed to by PubSub.
@@ -141,7 +121,7 @@ def __init__(self):
141121

142122
self.pubsub_socket: any = None
143123
self.pubsub_callback: Callable[
144-
[SQLiteCloudConnect, Optional[types.SqliteCloudResultSet], Optional[any]],
124+
[SQLiteCloudConnect, Optional[SQLiteCloudResultSet], Optional[any]],
145125
None,
146126
] = None
147127
self.pubsub_data: any = None
@@ -210,8 +190,6 @@ def _parse_connection_string(self, connection_string) -> None:
210190
value = bool(value)
211191
elif value.isdigit():
212192
value = int(value)
213-
else:
214-
value = value
215193

216194
# alias
217195
if opt == "nonlinearizable":
@@ -248,6 +226,7 @@ def _parse_connection_string(self, connection_string) -> None:
248226

249227
class SQLiteCloudException(Exception):
250228
def __init__(self, message: str, code: int = -1, xerrcode: int = 0) -> None:
229+
super().__init__(message)
251230
self.errmsg = str(message)
252231
self.errcode = code
253232
self.xerrcode = xerrcode

src/sqlitecloud/dbapi2.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@
1616
overload,
1717
)
1818

19-
from sqlitecloud.driver import Driver
20-
from sqlitecloud.resultset import SQLiteCloudResult
21-
from sqlitecloud.types import (
22-
SQLITECLOUD_RESULT_TYPE,
19+
from sqlitecloud.datatypes import (
2320
SQLiteCloudAccount,
2421
SQLiteCloudConfig,
2522
SQLiteCloudConnect,
2623
SQLiteCloudDataTypes,
2724
SQLiteCloudException,
2825
)
26+
from sqlitecloud.driver import Driver
27+
from sqlitecloud.resultset import SQLITECLOUD_RESULT_TYPE, SQLiteCloudResult
2928

3029
# Question mark style, e.g. ...WHERE name=?
3130
# Module also supports Named style, e.g. ...WHERE name=:name
@@ -478,7 +477,7 @@ def __next__(self) -> Optional[Tuple[Any]]:
478477
and self._resultset.data
479478
and self._iter_row < self._resultset.nrows
480479
):
481-
out: tuple[Any] = ()
480+
out: Tuple[Any] = ()
482481

483482
for col in range(self._resultset.ncols):
484483
out += (self._resultset.get_value(self._iter_row, col),)

src/sqlitecloud/download.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import logging
22
from io import BufferedWriter
33

4+
from sqlitecloud.datatypes import SQLiteCloudConnect
45
from sqlitecloud.driver import Driver
5-
from sqlitecloud.types import SQLiteCloudConnect
66

77

88
def xCallback(

0 commit comments

Comments
 (0)