sqlthon 0.1.0__tar.gz → 0.1.1__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.
- {sqlthon-0.1.0 → sqlthon-0.1.1}/PKG-INFO +1 -1
- {sqlthon-0.1.0 → sqlthon-0.1.1}/pyproject.toml +1 -1
- {sqlthon-0.1.0 → sqlthon-0.1.1}/src/sqlthon/__init__.py +1 -1
- {sqlthon-0.1.0 → sqlthon-0.1.1}/src/sqlthon/core.py +16 -11
- {sqlthon-0.1.0 → sqlthon-0.1.1}/src/sqlthon.egg-info/PKG-INFO +1 -1
- {sqlthon-0.1.0 → sqlthon-0.1.1}/README.md +0 -0
- {sqlthon-0.1.0 → sqlthon-0.1.1}/setup.cfg +0 -0
- {sqlthon-0.1.0 → sqlthon-0.1.1}/src/sqlthon/keywords.py +0 -0
- {sqlthon-0.1.0 → sqlthon-0.1.1}/src/sqlthon.egg-info/SOURCES.txt +0 -0
- {sqlthon-0.1.0 → sqlthon-0.1.1}/src/sqlthon.egg-info/dependency_links.txt +0 -0
- {sqlthon-0.1.0 → sqlthon-0.1.1}/src/sqlthon.egg-info/top_level.txt +0 -0
|
@@ -15,7 +15,7 @@ Channel: https://ble.ir/saums_channel
|
|
|
15
15
|
from .core import Connect, Field
|
|
16
16
|
|
|
17
17
|
__all__ = ['Connect', 'Field']
|
|
18
|
-
__version__ = '0.1.
|
|
18
|
+
__version__ = '0.1.1'
|
|
19
19
|
__author__ = "SAUMS"
|
|
20
20
|
__email__ = "saums1391@gmail.com"
|
|
21
21
|
__description__ = "Operate With SQLite3 Buy Simple"
|
|
@@ -99,8 +99,15 @@ def _analysis_code(query):
|
|
|
99
99
|
for i in query:
|
|
100
100
|
_analysis_code(i)
|
|
101
101
|
return
|
|
102
|
-
if not match("^[A-Za-z_][A-Za-z0-9_.(), ]*$", query) or
|
|
103
|
-
|
|
102
|
+
if not match("^[A-Za-z_][A-Za-z0-9_.(), ]*$", query) or any(word in query.lower() for word in ("sqlite_", "union", "select", "blob", "pragma")):
|
|
103
|
+
for i in {"NOT", "NULL", "PRIMARY", "KEY", "UNIQUE", "DEFAULT",
|
|
104
|
+
"CHECK", "AUTOINCREMENT", "REFERENCES", "COLLATE",
|
|
105
|
+
"TRUE", "FALSE", "CURRENT_TIMESTAMP", "ON", "DELETE",
|
|
106
|
+
"UPDATE", "CASCADE", "RESTRICT", "SET", "NO", "ACTION",
|
|
107
|
+
"PRECISION", "DOUBLE", "UNSIGNED", "BIG", "INT",
|
|
108
|
+
"NATIVE", "CHARACTER", "VARYING",}:
|
|
109
|
+
if not i in query:
|
|
110
|
+
raise YouHackerError(f"you hacker for {query!r}.") from None
|
|
104
111
|
|
|
105
112
|
|
|
106
113
|
class Connect:
|
|
@@ -125,7 +132,7 @@ class Connect:
|
|
|
125
132
|
name, type = column[0], column[1]
|
|
126
133
|
try:
|
|
127
134
|
limits = column[2]
|
|
128
|
-
query += f"{name} {type} {" ".join(limits)}"
|
|
135
|
+
query += f"""{name} {type} {" ".join(limits)}"""
|
|
129
136
|
except:
|
|
130
137
|
query += f"{name} {type}"
|
|
131
138
|
|
|
@@ -195,7 +202,7 @@ class Connect:
|
|
|
195
202
|
query += "DISTINCT "
|
|
196
203
|
if columns:
|
|
197
204
|
_analysis_code(columns)
|
|
198
|
-
query += f"{
|
|
205
|
+
query += f"""{", ".join(columns) if columns else "*"} FROM {table_name}"""
|
|
199
206
|
if compound:
|
|
200
207
|
if compound[0].upper() not in ("INNER", "LEFT"):
|
|
201
208
|
raise YouHackerError(f"you hacker for {query!r}.") from None
|
|
@@ -234,12 +241,12 @@ class Connect:
|
|
|
234
241
|
|
|
235
242
|
def add_record(self, table_name: str, record_info: tuple) -> None:
|
|
236
243
|
_analysis_code(table_name)
|
|
237
|
-
self._changes.append((f"INSERT INTO {table_name} VALUES({
|
|
244
|
+
self._changes.append((f"""INSERT INTO {table_name} VALUES({", ".join(["?"]*len(record_info))})""", record_info))
|
|
238
245
|
|
|
239
246
|
def add_records(self, table_name: str, info_records: tuple) -> None:
|
|
240
247
|
_analysis_code(table_name)
|
|
241
248
|
try:
|
|
242
|
-
self._cur.executemany(f"INSERT INTO {table_name} VALUES ({", ".join(["?"]*len(info_records[0]))})", info_records)
|
|
249
|
+
self._cur.executemany(f"""INSERT INTO {table_name} VALUES ({", ".join(["?"]*len(info_records[0]))})""", info_records)
|
|
243
250
|
self._con.commit()
|
|
244
251
|
except Exception as e:
|
|
245
252
|
_handler_error(e)
|
|
@@ -281,7 +288,7 @@ class Connect:
|
|
|
281
288
|
def upsert_record(self, table_name: str, info_record: tuple, conflict: tuple) -> None:
|
|
282
289
|
_analysis_code(table_name)
|
|
283
290
|
_analysis_code(conflict)
|
|
284
|
-
query = f"INSERT INTO {table_name} VALUES ({", ".join(["?"]*len(info_record))}) ON CONFLICT(\"{'", "'.join(conflict)}\") DO UPDATE SET "
|
|
291
|
+
query = f"""INSERT INTO {table_name} VALUES ({", ".join(["?"]*len(info_record))}) ON CONFLICT(\"{'", "'.join(conflict)}\") DO UPDATE SET """
|
|
285
292
|
param = info_record
|
|
286
293
|
colue = dict(zip(self.get_columns(table_name), info_record)) # columns value
|
|
287
294
|
for i in conflict:
|
|
@@ -368,7 +375,7 @@ class Connect:
|
|
|
368
375
|
if not abspath(csv_path).startswith(allowed_dir):
|
|
369
376
|
raise YouHackerError(f"you hacker for {csv_path!r}.")
|
|
370
377
|
import csv as _csv
|
|
371
|
-
with open(csv_path, "w"
|
|
378
|
+
with open(csv_path, "w") as f:
|
|
372
379
|
writer = _csv.writer(f)
|
|
373
380
|
writer.writerow(self.get_columns(table_name))
|
|
374
381
|
for row in self.find_record(table_name):
|
|
@@ -401,11 +408,9 @@ class Connect:
|
|
|
401
408
|
with self._con:
|
|
402
409
|
for sql_code in self._changes:
|
|
403
410
|
self._cur.execute(*sql_code)
|
|
411
|
+
self._changes.clear()
|
|
404
412
|
except Exception as e:
|
|
405
413
|
_handler_error(e)
|
|
406
|
-
|
|
407
|
-
finally:
|
|
408
|
-
self._changes.clear()
|
|
409
414
|
|
|
410
415
|
def close(self):
|
|
411
416
|
self._con.close()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|