dbhydra 1.2.6__tar.gz → 1.2.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbhydra
3
- Version: 1.2.6
3
+ Version: 1.2.7
4
4
  Summary: Data science friendly ORM combining Python
5
5
  Home-page: https://github.com/DovaX/dbhydra
6
6
  Author: DovaX
@@ -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
- self.connection = MySQLdb.connect(host=self.DB_SERVER, port=self.DB_PORT, user=self.DB_USERNAME, password=self.DB_PASSWORD, database=self.DB_DATABASE)
486
- self.cursor = self.connection.cursor()
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 = [x for x in self.types if x!=self.id_column_name]
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 ["JSON", "text", "mediumtext", "longtext", "datetime"]:
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
- query += self.columns[i] + ","
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
- 'jsonable': "str"
1756
+ 'Jsonable': "str"
1746
1757
  }
1747
1758
 
1748
1759
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbhydra
3
- Version: 1.2.6
3
+ Version: 1.2.7
4
4
  Summary: Data science friendly ORM combining Python
5
5
  Home-page: https://github.com/DovaX/dbhydra
6
6
  Author: DovaX
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name='dbhydra',
8
- version='1.2.6',
8
+ version='1.2.7',
9
9
  author='DovaX',
10
10
  author_email='dovax.ai@gmail.com',
11
11
  description='Data science friendly ORM combining Python',
File without changes
File without changes
File without changes
File without changes