dbhydra 2.2.9__tar.gz → 2.2.11__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.9 → dbhydra-2.2.11}/PKG-INFO +1 -1
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/src/abstract_db.py +12 -2
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/src/abstract_table.py +5 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/src/mysql_db.py +4 -1
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra.egg-info/PKG-INFO +1 -1
- {dbhydra-2.2.9 → dbhydra-2.2.11}/setup.py +1 -1
- {dbhydra-2.2.9 → dbhydra-2.2.11}/LICENSE +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/README.md +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/__init__.py +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/dbhydra_core.py +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/src/__init__.py +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/src/bigquery_db.py +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/src/errors/__init__.py +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/src/errors/exceptions.py +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/src/migrator.py +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/src/mongo_db.py +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/src/postgres_db.py +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/src/sqlserver_db.py +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/src/tables.py +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/src/xlsx_db.py +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/test_migrator.py +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/tests/__init__.py +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/tests/test_cases.py +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/tests/test_mongo.py +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra/tests/test_sql.py +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra.egg-info/SOURCES.txt +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra.egg-info/dependency_links.txt +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra.egg-info/requires.txt +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/dbhydra.egg-info/top_level.txt +0 -0
- {dbhydra-2.2.9 → dbhydra-2.2.11}/setup.cfg +0 -0
|
@@ -2,7 +2,7 @@ import abc
|
|
|
2
2
|
import threading
|
|
3
3
|
from contextlib import contextmanager
|
|
4
4
|
from typing import Optional
|
|
5
|
-
|
|
5
|
+
import time
|
|
6
6
|
from dbhydra.src.migrator import Migrator
|
|
7
7
|
from dbhydra.src.tables import AbstractTable
|
|
8
8
|
|
|
@@ -73,7 +73,7 @@ class AbstractDb(abc.ABC):
|
|
|
73
73
|
# 'AbstractSet': set,
|
|
74
74
|
}
|
|
75
75
|
python_database_type_mapping = {}
|
|
76
|
-
def __init__(self, config_file="config.ini", db_details=None):
|
|
76
|
+
def __init__(self, config_file="config.ini", db_details=None, debug_mode=False):
|
|
77
77
|
if db_details is None:
|
|
78
78
|
db_details = read_connection_details(config_file)
|
|
79
79
|
|
|
@@ -87,6 +87,7 @@ class AbstractDb(abc.ABC):
|
|
|
87
87
|
self.DB_PASSWORD = db_details["DB_PASSWORD"]
|
|
88
88
|
|
|
89
89
|
self.is_autocommiting=True
|
|
90
|
+
self.debug_mode = debug_mode
|
|
90
91
|
|
|
91
92
|
if "DB_PORT" in db_details.keys():
|
|
92
93
|
self.DB_PORT = int(db_details["DB_PORT"])
|
|
@@ -153,9 +154,15 @@ class AbstractDb(abc.ABC):
|
|
|
153
154
|
@contextmanager
|
|
154
155
|
def connect_to_db(self):
|
|
155
156
|
try:
|
|
157
|
+
if self.debug_mode:
|
|
158
|
+
with open("dbhydra_logs.txt","a+") as file:
|
|
159
|
+
file.write(str(time.now())+": DB "+str(self)+": _connect() called")
|
|
156
160
|
self._connect()
|
|
157
161
|
yield None
|
|
158
162
|
finally:
|
|
163
|
+
if self.debug_mode:
|
|
164
|
+
with open("dbhydra_logs.txt","a+") as file:
|
|
165
|
+
file.write(str(time.now())+": DB "+str(self)+": close_connection() called")
|
|
159
166
|
self.close_connection()
|
|
160
167
|
|
|
161
168
|
@contextmanager
|
|
@@ -188,6 +195,9 @@ class AbstractDb(abc.ABC):
|
|
|
188
195
|
result=self.cursor.execute(query)
|
|
189
196
|
if self.is_autocommitting:
|
|
190
197
|
self.cursor.commit()
|
|
198
|
+
if self.debug_mode:
|
|
199
|
+
with open("dbhydra_logs.txt","a+") as file:
|
|
200
|
+
file.write(str(time.now())+": DB "+str(self)+": execute() called with query: "+str(query))
|
|
191
201
|
return(result)
|
|
192
202
|
|
|
193
203
|
def close_connection(self):
|
|
@@ -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
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import time
|
|
4
4
|
import pymysql
|
|
5
5
|
from dbhydra.src.abstract_db import AbstractDb
|
|
6
6
|
from dbhydra.src.tables import MysqlTable
|
|
@@ -55,6 +55,9 @@ class MysqlDb(AbstractDb):
|
|
|
55
55
|
result=self.cursor.execute(query)
|
|
56
56
|
if is_autocommitting:
|
|
57
57
|
self.connection.commit()
|
|
58
|
+
if self.debug_mode:
|
|
59
|
+
with open("dbhydra_logs.txt","a+") as file:
|
|
60
|
+
file.write(str(time.now())+": DB "+str(self)+": execute() called with query: "+str(query))
|
|
58
61
|
return result
|
|
59
62
|
|
|
60
63
|
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|