dbhydra 2.2.3__tar.gz → 2.2.5__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.3 → dbhydra-2.2.5}/PKG-INFO +1 -1
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/src/abstract_table.py +9 -7
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/src/tables.py +12 -10
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra.egg-info/PKG-INFO +1 -1
- {dbhydra-2.2.3 → dbhydra-2.2.5}/setup.py +1 -1
- {dbhydra-2.2.3 → dbhydra-2.2.5}/LICENSE +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/README.md +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/__init__.py +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/dbhydra_core.py +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/src/__init__.py +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/src/abstract_db.py +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/src/bigquery_db.py +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/src/errors/__init__.py +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/src/errors/exceptions.py +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/src/migrator.py +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/src/mongo_db.py +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/src/mysql_db.py +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/src/postgres_db.py +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/src/sqlserver_db.py +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/src/xlsx_db.py +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/test_migrator.py +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/tests/__init__.py +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/tests/test_cases.py +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/tests/test_mongo.py +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra/tests/test_sql.py +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra.egg-info/SOURCES.txt +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra.egg-info/dependency_links.txt +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra.egg-info/requires.txt +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/dbhydra.egg-info/top_level.txt +0 -0
- {dbhydra-2.2.3 → dbhydra-2.2.5}/setup.cfg +0 -0
|
@@ -258,21 +258,23 @@ class AbstractTable(AbstractJoinable, abc.ABC):
|
|
|
258
258
|
return cls(db1, name, columns, types, id_column_name=id_column_name)
|
|
259
259
|
|
|
260
260
|
|
|
261
|
-
def drop(self):
|
|
261
|
+
def drop(self, debug_mode = False):
|
|
262
262
|
query = "DROP TABLE " + self.name
|
|
263
|
-
|
|
263
|
+
if debug_mode:
|
|
264
|
+
print(query)
|
|
264
265
|
self.execute(query)
|
|
265
266
|
|
|
266
|
-
def update(self, variable_assign, where=None):
|
|
267
|
+
def update(self, variable_assign, where=None, debug_mode = False):
|
|
267
268
|
if where is None:
|
|
268
269
|
query = "UPDATE " + self.name + " SET " + variable_assign
|
|
269
270
|
else:
|
|
270
271
|
query = "UPDATE " + self.name + " SET " + variable_assign + " WHERE " + where
|
|
271
|
-
|
|
272
|
+
if debug_mode:
|
|
273
|
+
print(query)
|
|
272
274
|
return self.execute(query)
|
|
273
275
|
|
|
274
276
|
def update_from_df(
|
|
275
|
-
self, update_df: pd.DataFrame, where_column: Optional[str] = None, where_value: Any = None) -> None:
|
|
277
|
+
self, update_df: pd.DataFrame, where_column: Optional[str] = None, where_value: Any = None, debug_mode = False) -> None:
|
|
276
278
|
"""Build UPDATE SQL query from a dataframe and execute it.
|
|
277
279
|
|
|
278
280
|
:param update_df: Dataframe with updated values - MUST only hold a single row
|
|
@@ -322,8 +324,8 @@ class AbstractTable(AbstractJoinable, abc.ABC):
|
|
|
322
324
|
sql_query += f" WHERE {where_column} = {where_value};"
|
|
323
325
|
else:
|
|
324
326
|
sql_query += ";"
|
|
325
|
-
|
|
326
|
-
|
|
327
|
+
if debug_mode:
|
|
328
|
+
print(sql_query)
|
|
327
329
|
self.execute(sql_query)
|
|
328
330
|
|
|
329
331
|
def _adjust_df(self, df: pd.DataFrame, debug_mode=False) -> pd.DataFrame:
|
|
@@ -141,7 +141,7 @@ class PostgresTable(AbstractTable):
|
|
|
141
141
|
return (cls(db1, name, columns, types))
|
|
142
142
|
|
|
143
143
|
# @save_migration
|
|
144
|
-
def create(self, foreign_keys=None):
|
|
144
|
+
def create(self, foreign_keys=None, debug_mode = False):
|
|
145
145
|
assert len(self.columns) == len(self.types)
|
|
146
146
|
assert self.columns[0] == self.id_column_name
|
|
147
147
|
assert self.types[0].lower() == "int" or self.types[0].lower() == "integer"
|
|
@@ -151,7 +151,8 @@ class PostgresTable(AbstractTable):
|
|
|
151
151
|
|
|
152
152
|
query = query[:-1]
|
|
153
153
|
query += ");"
|
|
154
|
-
|
|
154
|
+
if debug_mode:
|
|
155
|
+
print(query)
|
|
155
156
|
try:
|
|
156
157
|
self.db1.execute(query)
|
|
157
158
|
except Exception as e:
|
|
@@ -495,7 +496,7 @@ class SqlServerTable(AbstractTable):
|
|
|
495
496
|
types = information_schema_table.select(query)
|
|
496
497
|
return (types)
|
|
497
498
|
|
|
498
|
-
def create(self):
|
|
499
|
+
def create(self, debug_mode = False):
|
|
499
500
|
assert len(self.columns) == len(self.types)
|
|
500
501
|
assert self.columns[0] == self.id_column_name
|
|
501
502
|
assert self.types[0].lower() == "int"
|
|
@@ -503,8 +504,8 @@ class SqlServerTable(AbstractTable):
|
|
|
503
504
|
for i in range(1, len(self.columns)):
|
|
504
505
|
query += self.columns[i] + " " + self.types[i] + ","
|
|
505
506
|
query += "PRIMARY KEY("+self.id_column_name+"))"
|
|
506
|
-
|
|
507
|
-
|
|
507
|
+
if debug_mode:
|
|
508
|
+
print(query)
|
|
508
509
|
try:
|
|
509
510
|
self.db1.execute(query)
|
|
510
511
|
except Exception as e:
|
|
@@ -729,13 +730,14 @@ class MysqlTable(AbstractTable):
|
|
|
729
730
|
|
|
730
731
|
return num_of_records[0][0]
|
|
731
732
|
|
|
732
|
-
def drop(self):
|
|
733
|
+
def drop(self, debug_mode = False):
|
|
733
734
|
query = "DROP TABLE `" + self.name + "`;"
|
|
734
|
-
|
|
735
|
+
if debug_mode:
|
|
736
|
+
print(query)
|
|
735
737
|
self.db1.execute(query)
|
|
736
738
|
|
|
737
739
|
# @save_migration #TODO: Uncomment
|
|
738
|
-
def create(self, foreign_keys=None):
|
|
740
|
+
def create(self, foreign_keys=None, debug_mode = False):
|
|
739
741
|
assert len(self.columns) == len(self.types)
|
|
740
742
|
assert self.columns[0] == self.id_column_name
|
|
741
743
|
assert self.types[0].lower() == "int"
|
|
@@ -745,8 +747,8 @@ class MysqlTable(AbstractTable):
|
|
|
745
747
|
[f"`{column}` {type_.upper()}" for column, type_ in column_type_pairs]
|
|
746
748
|
)
|
|
747
749
|
query = f"CREATE TABLE `{self.name}` ({self.id_column_name} INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, {fields})"
|
|
748
|
-
|
|
749
|
-
|
|
750
|
+
if debug_mode:
|
|
751
|
+
print(query)
|
|
750
752
|
try:
|
|
751
753
|
self.db1.execute(query)
|
|
752
754
|
except Exception as e:
|
|
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
|
|
File without changes
|