dbhydra 2.2.8__tar.gz → 2.2.10__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.
- {dbhydra-2.2.8 → dbhydra-2.2.10}/PKG-INFO +1 -1
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/dbhydra_core.py +2 -2
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/src/abstract_db.py +1 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/src/abstract_table.py +5 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/src/mysql_db.py +1 -1
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/src/tables.py +10 -1
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/src/xlsx_db.py +2 -1
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra.egg-info/PKG-INFO +1 -1
- {dbhydra-2.2.8 → dbhydra-2.2.10}/setup.py +1 -1
- {dbhydra-2.2.8 → dbhydra-2.2.10}/LICENSE +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/README.md +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/__init__.py +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/src/__init__.py +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/src/bigquery_db.py +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/src/errors/__init__.py +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/src/errors/exceptions.py +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/src/migrator.py +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/src/mongo_db.py +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/src/postgres_db.py +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/src/sqlserver_db.py +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/test_migrator.py +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/tests/__init__.py +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/tests/test_cases.py +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/tests/test_mongo.py +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra/tests/test_sql.py +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra.egg-info/SOURCES.txt +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra.egg-info/dependency_links.txt +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra.egg-info/requires.txt +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/dbhydra.egg-info/top_level.txt +0 -0
- {dbhydra-2.2.8 → dbhydra-2.2.10}/setup.cfg +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import binascii
|
|
1
2
|
import pandas as pd
|
|
2
3
|
from typing import Optional, Any
|
|
3
4
|
import numpy as np
|
|
@@ -317,6 +318,10 @@ class AbstractTable(AbstractJoinable, abc.ABC):
|
|
|
317
318
|
column_value_string += f"{quote}{column_name}{quote} = '{cell_value}', "
|
|
318
319
|
elif column_type in ["json", "text", "mediumtext", "longtext", "datetime"]:
|
|
319
320
|
column_value_string += f"{quote}{column_name}{quote} = '{cell_value}', "
|
|
321
|
+
elif 'blob' in column_type:
|
|
322
|
+
# Convert to hex to allow insertion into SQL query
|
|
323
|
+
hex_data = binascii.hexlify(cell_value).decode('ascii')
|
|
324
|
+
column_value_string += f"{quote}{column_name}{quote} = UNHEX('{hex_data}'), "
|
|
320
325
|
else:
|
|
321
326
|
raise AttributeError(f"Unknown column type '{column_type}'")
|
|
322
327
|
|
|
@@ -5,7 +5,6 @@ import abc
|
|
|
5
5
|
import time
|
|
6
6
|
#xlsx imports
|
|
7
7
|
import pathlib
|
|
8
|
-
import pymysql
|
|
9
8
|
from dbhydra.src.abstract_table import AbstractTable, AbstractSelectable, AbstractJoinable
|
|
10
9
|
import binascii
|
|
11
10
|
|
|
@@ -906,6 +905,11 @@ class XlsxTable(AbstractTable):
|
|
|
906
905
|
self.table_directory_path: pathlib.Path = self.db1.db_directory_path / table_filename
|
|
907
906
|
|
|
908
907
|
def _save_table(self, df: pd.DataFrame):
|
|
908
|
+
blob_columns = [
|
|
909
|
+
column for column, type_ in self.column_type_dict.items() if type_ == "Blob"
|
|
910
|
+
]
|
|
911
|
+
df[blob_columns] = df[blob_columns].map(lambda x: x.hex() if x is not None else None)
|
|
912
|
+
|
|
909
913
|
if self.db1.is_csv:
|
|
910
914
|
df.to_csv(self.table_directory_path, index=False)
|
|
911
915
|
else:
|
|
@@ -963,6 +967,9 @@ class XlsxTable(AbstractTable):
|
|
|
963
967
|
date_columns = [
|
|
964
968
|
column for column, type_ in self.column_type_dict.items() if type_ == "datetime"
|
|
965
969
|
]
|
|
970
|
+
blob_columns = [
|
|
971
|
+
column for column, type_ in self.column_type_dict.items() if type_ == "Blob"
|
|
972
|
+
]
|
|
966
973
|
|
|
967
974
|
# BUG: If XlsxTable is being accessed by multiple threads, read operation
|
|
968
975
|
# might fail due to race conditions. Add retry mechanism to handle these cases.
|
|
@@ -977,6 +984,8 @@ class XlsxTable(AbstractTable):
|
|
|
977
984
|
else:
|
|
978
985
|
print(f"Failed to read data from {self.table_directory_path}, returning empty DataFrame")
|
|
979
986
|
df = pd.DataFrame(columns=self.columns)
|
|
987
|
+
|
|
988
|
+
df[blob_columns] = df[blob_columns].map(lambda x: bytes.fromhex(x) if x else None)
|
|
980
989
|
return df
|
|
981
990
|
|
|
982
991
|
def _select(self, column_type_map, date_columns):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|