dbhydra 1.2.6__py3-none-any.whl → 1.2.7__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 +19 -8
- {dbhydra-1.2.6.dist-info → dbhydra-1.2.7.dist-info}/METADATA +1 -1
- {dbhydra-1.2.6.dist-info → dbhydra-1.2.7.dist-info}/RECORD +6 -6
- {dbhydra-1.2.6.dist-info → dbhydra-1.2.7.dist-info}/LICENSE +0 -0
- {dbhydra-1.2.6.dist-info → dbhydra-1.2.7.dist-info}/WHEEL +0 -0
- {dbhydra-1.2.6.dist-info → dbhydra-1.2.7.dist-info}/top_level.txt +0 -0
dbhydra/dbhydra_core.py
CHANGED
|
@@ -252,6 +252,7 @@ class AbstractDB(abc.ABC):
|
|
|
252
252
|
'Set': 'set',
|
|
253
253
|
'Union': 'object',
|
|
254
254
|
'Optional': 'object',
|
|
255
|
+
'Jsonable': 'Jsonable',
|
|
255
256
|
# 'FrozenSet': frozenset,
|
|
256
257
|
# 'Deque': list,
|
|
257
258
|
# 'Any': object,
|
|
@@ -481,9 +482,9 @@ class Mysqldb(AbstractDB):
|
|
|
481
482
|
'Jsonable': "json"
|
|
482
483
|
}
|
|
483
484
|
|
|
484
|
-
def connect_to_db(self):
|
|
485
|
-
|
|
486
|
-
|
|
485
|
+
#def connect_to_db(self):
|
|
486
|
+
# self.connection = MySQLdb.connect(host=self.DB_SERVER, port=self.DB_PORT, user=self.DB_USERNAME, password=self.DB_PASSWORD, database=self.DB_DATABASE)
|
|
487
|
+
# self.cursor = self.connection.cursor()
|
|
487
488
|
|
|
488
489
|
# NOT USED, BUT FORCED BY ABSTRACT CLASS
|
|
489
490
|
def connect_locally(self):
|
|
@@ -811,8 +812,8 @@ class AbstractTable(AbstractJoinable, abc.ABC):
|
|
|
811
812
|
if not len(update_df) == 1:
|
|
812
813
|
raise ValueError("There can only be one row in the UPDATE dataframe")
|
|
813
814
|
|
|
814
|
-
types_without_id_column = [
|
|
815
|
-
|
|
815
|
+
types_without_id_column = [type_ for column, type_ in zip(self.columns, self.types)
|
|
816
|
+
if column != self.id_column_name]
|
|
816
817
|
if len(types_without_id_column) != len(update_df.columns):
|
|
817
818
|
raise AttributeError(
|
|
818
819
|
"Number of columns in dataframe does not match number of columns in table"
|
|
@@ -826,7 +827,7 @@ class AbstractTable(AbstractJoinable, abc.ABC):
|
|
|
826
827
|
column_value_string += f"{column} = {cell_value}, "
|
|
827
828
|
elif "varchar" in column_type:
|
|
828
829
|
column_value_string += f"{column} = '{cell_value}', "
|
|
829
|
-
elif column_type in ["
|
|
830
|
+
elif column_type in ["json", "text", "mediumtext", "longtext", "datetime"]:
|
|
830
831
|
column_value_string += f"{column} = '{cell_value}', "
|
|
831
832
|
else:
|
|
832
833
|
raise AttributeError(f"Unknown column type '{column_type}'")
|
|
@@ -1598,7 +1599,12 @@ class MysqlTable(MysqlSelectable, AbstractTable):
|
|
|
1598
1599
|
query = "INSERT INTO " + self.name + " ("
|
|
1599
1600
|
for i in range(start_index, len(self.columns)):
|
|
1600
1601
|
if i < len(rows[k]) + 1:
|
|
1601
|
-
|
|
1602
|
+
# column name containing space needs to be wrapped in `...`, otherwise causes syntax error
|
|
1603
|
+
if " " in self.columns[i]:
|
|
1604
|
+
column_name = '`' + self.columns[i] + '`'
|
|
1605
|
+
else:
|
|
1606
|
+
column_name = self.columns[i]
|
|
1607
|
+
query += column_name + ","
|
|
1602
1608
|
if len(rows) < len(self.columns):
|
|
1603
1609
|
print(len(self.columns) - len(rows), "columns were not specified")
|
|
1604
1610
|
if query[-1] == ',':
|
|
@@ -1624,6 +1630,10 @@ class MysqlTable(MysqlSelectable, AbstractTable):
|
|
|
1624
1630
|
if replace_apostrophes:
|
|
1625
1631
|
rows[k][j] = str(rows[k][j]).replace("'", "")
|
|
1626
1632
|
query += "'" + str(rows[k][j]) + "',"
|
|
1633
|
+
elif "char" in self.types[j + start_index]:
|
|
1634
|
+
if replace_apostrophes:
|
|
1635
|
+
rows[k][j] = str(rows[k][j]).replace("'", "")
|
|
1636
|
+
query += "'" + str(rows[k][j]) + "',"
|
|
1627
1637
|
elif self.types[j + start_index] == "int":
|
|
1628
1638
|
query += str(rows[k][j]) + ","
|
|
1629
1639
|
elif "datetime" in self.types[j + start_index]:
|
|
@@ -1720,6 +1730,7 @@ class MysqlTable(MysqlSelectable, AbstractTable):
|
|
|
1720
1730
|
|
|
1721
1731
|
class XlsxDB(AbstractDB):
|
|
1722
1732
|
def __init__(self, config_file="config.ini", db_details=None):
|
|
1733
|
+
self.locally=True
|
|
1723
1734
|
if db_details is None:
|
|
1724
1735
|
self.name="new_db"
|
|
1725
1736
|
self.directory_path = None
|
|
@@ -1742,7 +1753,7 @@ class XlsxDB(AbstractDB):
|
|
|
1742
1753
|
'dict': "str",
|
|
1743
1754
|
'bool': "bool",
|
|
1744
1755
|
'datetime': "datetime",
|
|
1745
|
-
'
|
|
1756
|
+
'Jsonable': "str"
|
|
1746
1757
|
}
|
|
1747
1758
|
|
|
1748
1759
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
dbhydra/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
dbhydra/dbhydra_builder.py,sha256=3XNP3GJ5m9UdAO2_qCRipHXzRrtB5QGFUoSjFIh2chQ,1682
|
|
3
|
-
dbhydra/dbhydra_core.py,sha256=
|
|
3
|
+
dbhydra/dbhydra_core.py,sha256=DUGwU3giNnH3uZbIQnaOth_hEpQOOtN0eYpoaY4p2Zc,78181
|
|
4
4
|
dbhydra/dbhydra_liquibase.py,sha256=39Y9g8zBQjbU3WL1u5pL-i598LauZ8VVMBraLU-OZO8,2405
|
|
5
5
|
dbhydra/dbhydra_model.py,sha256=sgY_Nz7dLaVa6EDmJUABxUDFwzJvUqrvMKcz1QGDXzM,757
|
|
6
6
|
dbhydra/dbhydra_mysql_example - kopie.py,sha256=lgPZ7to7iSW8Ad6c1pUYLv9R9jA-j6wWV1BqfQBGwUQ,337
|
|
@@ -13,8 +13,8 @@ dbhydra/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
13
13
|
dbhydra/tests/test_cases.py,sha256=eAFGaHaIaab3md3HHm2_ryb_HHfObtcXDAEzLh4qWx8,508
|
|
14
14
|
dbhydra/tests/test_mongo.py,sha256=M8TD72M0iQAk7ZcLTWwLmcmmF_zwALnYEGTWjhQlq0s,1979
|
|
15
15
|
dbhydra/tests/test_sql.py,sha256=aPFXyA0jh8o9VG3B5f9fNz7qDbuVPZ9TcE2twn5dAeQ,3126
|
|
16
|
-
dbhydra-1.2.
|
|
17
|
-
dbhydra-1.2.
|
|
18
|
-
dbhydra-1.2.
|
|
19
|
-
dbhydra-1.2.
|
|
20
|
-
dbhydra-1.2.
|
|
16
|
+
dbhydra-1.2.7.dist-info/LICENSE,sha256=k49Yga8CP889JJaHlOpGFzr_be2nqMoep2chYeIDctk,1091
|
|
17
|
+
dbhydra-1.2.7.dist-info/METADATA,sha256=bMol26BTr91xGaNZtCAqgCvyUO0pYqlnvXdF4N8KSS8,2179
|
|
18
|
+
dbhydra-1.2.7.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
|
19
|
+
dbhydra-1.2.7.dist-info/top_level.txt,sha256=oO4Gf1T8_txIsIlp11GI0k7PtBIMb9GRwb5ObF4MLVg,8
|
|
20
|
+
dbhydra-1.2.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|