dbhydra 2.2.6__py3-none-any.whl → 2.2.8__py3-none-any.whl
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.
- dbhydra/dbhydra_core.py +3 -0
- dbhydra/src/abstract_table.py +14 -16
- dbhydra/src/mysql_db.py +2 -1
- dbhydra/src/tables.py +6 -3
- {dbhydra-2.2.6.dist-info → dbhydra-2.2.8.dist-info}/METADATA +1 -1
- {dbhydra-2.2.6.dist-info → dbhydra-2.2.8.dist-info}/RECORD +9 -9
- {dbhydra-2.2.6.dist-info → dbhydra-2.2.8.dist-info}/LICENSE +0 -0
- {dbhydra-2.2.6.dist-info → dbhydra-2.2.8.dist-info}/WHEEL +0 -0
- {dbhydra-2.2.6.dist-info → dbhydra-2.2.8.dist-info}/top_level.txt +0 -0
dbhydra/dbhydra_core.py
CHANGED
dbhydra/src/abstract_table.py
CHANGED
|
@@ -259,16 +259,19 @@ class AbstractTable(AbstractJoinable, abc.ABC):
|
|
|
259
259
|
|
|
260
260
|
|
|
261
261
|
def drop(self, debug_mode = False):
|
|
262
|
-
|
|
262
|
+
quote = self.db1.identifier_quote
|
|
263
|
+
query = f"DROP TABLE {quote}{self.name}{quote}"
|
|
263
264
|
if debug_mode:
|
|
264
265
|
print(query)
|
|
265
266
|
self.execute(query)
|
|
266
267
|
|
|
267
268
|
def update(self, variable_assign, where=None, debug_mode = False):
|
|
269
|
+
quote = self.db1.identifier_quote
|
|
268
270
|
if where is None:
|
|
269
|
-
query = "UPDATE
|
|
271
|
+
query = f"UPDATE {quote}{self.name}{quote} SET {quote}{variable_assign}{quote}"
|
|
270
272
|
else:
|
|
271
|
-
query = "UPDATE
|
|
273
|
+
query = f"UPDATE {quote}{self.name}{quote} SET {quote}{variable_assign}{quote} WHERE {quote}{where}{quote}"
|
|
274
|
+
|
|
272
275
|
if debug_mode:
|
|
273
276
|
print(query)
|
|
274
277
|
return self.execute(query)
|
|
@@ -303,25 +306,25 @@ class AbstractTable(AbstractJoinable, abc.ABC):
|
|
|
303
306
|
for column_name, column_type in types_without_id_column
|
|
304
307
|
]
|
|
305
308
|
|
|
309
|
+
quote = self.db1.identifier_quote
|
|
306
310
|
column_value_string = ""
|
|
307
311
|
for column_name, cell_value, column_type in update_df_row_list:
|
|
308
312
|
if cell_value is None:
|
|
309
|
-
column_value_string += f"{column_name} = NULL, "
|
|
313
|
+
column_value_string += f"{quote}{column_name}{quote} = NULL, "
|
|
310
314
|
elif column_type in ["double", "int", "tinyint"]:
|
|
311
|
-
column_value_string += f"{column_name} = {cell_value}, "
|
|
315
|
+
column_value_string += f"{quote}{column_name}{quote} = {cell_value}, "
|
|
312
316
|
elif "varchar" in column_type:
|
|
313
|
-
column_value_string += f"{column_name} = '{cell_value}', "
|
|
317
|
+
column_value_string += f"{quote}{column_name}{quote} = '{cell_value}', "
|
|
314
318
|
elif column_type in ["json", "text", "mediumtext", "longtext", "datetime"]:
|
|
315
|
-
column_value_string += f"{column_name} = '{cell_value}', "
|
|
319
|
+
column_value_string += f"{quote}{column_name}{quote} = '{cell_value}', "
|
|
316
320
|
else:
|
|
317
321
|
raise AttributeError(f"Unknown column type '{column_type}'")
|
|
318
322
|
|
|
319
323
|
column_value_string = column_value_string.rstrip(", ")
|
|
320
|
-
quote = self.db1.identifier_quote
|
|
321
324
|
sql_query = f"UPDATE {quote}{self.name}{quote} SET {column_value_string}"
|
|
322
325
|
|
|
323
326
|
if where_column is not None and where_value is not None:
|
|
324
|
-
sql_query += f" WHERE {where_column} = {where_value};"
|
|
327
|
+
sql_query += f" WHERE {quote}{where_column}{quote} = {where_value};"
|
|
325
328
|
else:
|
|
326
329
|
sql_query += ";"
|
|
327
330
|
if debug_mode:
|
|
@@ -382,7 +385,7 @@ class AbstractTable(AbstractJoinable, abc.ABC):
|
|
|
382
385
|
inserted_columns=list(dict.fromkeys(self.columns)) #DEDUPLICATION preserving order -> better than inserted_columns = set(self.columns)
|
|
383
386
|
id_index=inserted_columns.index(self.id_column_name)
|
|
384
387
|
inserted_columns.pop(id_index)
|
|
385
|
-
print(inserted_columns,df.columns)
|
|
388
|
+
# print(inserted_columns,df.columns)
|
|
386
389
|
|
|
387
390
|
assert set(df.columns) == set(inserted_columns) #elements are matchin
|
|
388
391
|
#df = df[inserted_columns]
|
|
@@ -429,12 +432,7 @@ class AbstractTable(AbstractJoinable, abc.ABC):
|
|
|
429
432
|
quote = self.db1.identifier_quote
|
|
430
433
|
|
|
431
434
|
if where is None:
|
|
432
|
-
query = "DELETE FROM {quote}{self.name}{quote}"
|
|
435
|
+
query = f"DELETE FROM {quote}{self.name}{quote}"
|
|
433
436
|
else:
|
|
434
437
|
query = f"DELETE FROM {quote}{self.name}{quote} WHERE {where}"
|
|
435
438
|
return self.execute(query)
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
dbhydra/src/mysql_db.py
CHANGED
dbhydra/src/tables.py
CHANGED
|
@@ -5,9 +5,9 @@ import abc
|
|
|
5
5
|
import time
|
|
6
6
|
#xlsx imports
|
|
7
7
|
import pathlib
|
|
8
|
-
|
|
8
|
+
import pymysql
|
|
9
9
|
from dbhydra.src.abstract_table import AbstractTable, AbstractSelectable, AbstractJoinable
|
|
10
|
-
|
|
10
|
+
import binascii
|
|
11
11
|
|
|
12
12
|
MONGO_OPERATOR_DICT = {"=": "$eq", ">": "$gt", ">=": "$gte", " IN ": "$in", "<": "$lt", "<=": "$lte", "<>": "$ne"}
|
|
13
13
|
|
|
@@ -807,7 +807,10 @@ class MysqlTable(AbstractTable):
|
|
|
807
807
|
query += "'" + str(rows[k][j]) + "',"
|
|
808
808
|
elif "json" in self.types[j + start_index]:
|
|
809
809
|
query += f"'{rows[k][j]}', "
|
|
810
|
-
|
|
810
|
+
elif 'blob' in self.types[j + start_index]:
|
|
811
|
+
# Convert to hex to allow insertion into SQL query
|
|
812
|
+
hex_data = binascii.hexlify(rows[k][j]).decode('ascii')
|
|
813
|
+
query += f"UNHEX('{hex_data}'), "
|
|
811
814
|
|
|
812
815
|
else:
|
|
813
816
|
query += str(rows[k][j]) + ","
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
dbhydra/__init__.py,sha256=DCocEeXf4QxdVlBRlNiFvuP5IZJ5aa77_DbUR-_4C14,65
|
|
2
|
-
dbhydra/dbhydra_core.py,sha256=
|
|
2
|
+
dbhydra/dbhydra_core.py,sha256=gMroDA_kVph7JFimbsNpGZ33f-qiGhw-su9EUkNN0bA,2537
|
|
3
3
|
dbhydra/test_migrator.py,sha256=e3Nnb2mCd3CfjhjSexNg1tXVJMjkl5cCoYcuhbfZ4pM,803
|
|
4
4
|
dbhydra/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
dbhydra/src/abstract_db.py,sha256=lEP24vWz0HdGjQgSoHnawNK_NvRlSLuvzVSiiawssuw,5901
|
|
6
|
-
dbhydra/src/abstract_table.py,sha256=
|
|
6
|
+
dbhydra/src/abstract_table.py,sha256=4oZO5if4wMbyEWtr5JkR6LPxbxjUwMVf4xITbE-2RXE,17755
|
|
7
7
|
dbhydra/src/bigquery_db.py,sha256=77XsgvYbANlvYaJnuVve-kz-PNBx_CHoYCL-eYnA8e4,1834
|
|
8
8
|
dbhydra/src/migrator.py,sha256=QzaODEFfraD9_6HN_Osaidaj-nLYQryCYYWwJtUu3n8,18931
|
|
9
9
|
dbhydra/src/mongo_db.py,sha256=mP48zRjI7mXKpm45R8prroZI-Eo7JKf0KJqGX-oTy3w,1922
|
|
10
|
-
dbhydra/src/mysql_db.py,sha256=
|
|
10
|
+
dbhydra/src/mysql_db.py,sha256=b0OV1nrYJBbzgTgBDKdLeENXQxKuYs_KhbvGvyymRf4,3180
|
|
11
11
|
dbhydra/src/postgres_db.py,sha256=L7MaBq_6ArwDSP_5LaEqK58oLxZ1X7FgIokcDOSB7wk,1805
|
|
12
12
|
dbhydra/src/sqlserver_db.py,sha256=9Xi3NAliqM79MTV8fpNQb0nWMH8Bqjl1leJSEqgyT94,3611
|
|
13
|
-
dbhydra/src/tables.py,sha256=
|
|
13
|
+
dbhydra/src/tables.py,sha256=F_WEookoyjv4r9HGfWdCquCc9MP5vH3vfonBPKNRQ3k,47184
|
|
14
14
|
dbhydra/src/xlsx_db.py,sha256=z6d-IjMYMmXC591Mt5DcxIYWyluanjPRFd-sXtjjXww,3514
|
|
15
15
|
dbhydra/src/errors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
16
|
dbhydra/src/errors/exceptions.py,sha256=LVpfbTd3NHfQIM-D5TFAU6hOZwGQ3b5DwFD4B6vtf2U,149
|
|
@@ -18,8 +18,8 @@ dbhydra/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
18
18
|
dbhydra/tests/test_cases.py,sha256=eAFGaHaIaab3md3HHm2_ryb_HHfObtcXDAEzLh4qWx8,508
|
|
19
19
|
dbhydra/tests/test_mongo.py,sha256=M8TD72M0iQAk7ZcLTWwLmcmmF_zwALnYEGTWjhQlq0s,1979
|
|
20
20
|
dbhydra/tests/test_sql.py,sha256=aPFXyA0jh8o9VG3B5f9fNz7qDbuVPZ9TcE2twn5dAeQ,3126
|
|
21
|
-
dbhydra-2.2.
|
|
22
|
-
dbhydra-2.2.
|
|
23
|
-
dbhydra-2.2.
|
|
24
|
-
dbhydra-2.2.
|
|
25
|
-
dbhydra-2.2.
|
|
21
|
+
dbhydra-2.2.8.dist-info/LICENSE,sha256=k49Yga8CP889JJaHlOpGFzr_be2nqMoep2chYeIDctk,1091
|
|
22
|
+
dbhydra-2.2.8.dist-info/METADATA,sha256=oHsjGJM9YAxfzovKPp2Nlwy9jqomXk1FZzuGBEEgWlM,2298
|
|
23
|
+
dbhydra-2.2.8.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
|
24
|
+
dbhydra-2.2.8.dist-info/top_level.txt,sha256=oO4Gf1T8_txIsIlp11GI0k7PtBIMb9GRwb5ObF4MLVg,8
|
|
25
|
+
dbhydra-2.2.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|