dbhydra 2.2.13__tar.gz → 2.2.16__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.
Files changed (30) hide show
  1. {dbhydra-2.2.13 → dbhydra-2.2.16}/PKG-INFO +1 -1
  2. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/src/abstract_db.py +5 -4
  3. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/src/abstract_table.py +18 -6
  4. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/src/mysql_db.py +1 -1
  5. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/src/tables.py +1 -1
  6. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra.egg-info/PKG-INFO +1 -1
  7. {dbhydra-2.2.13 → dbhydra-2.2.16}/setup.py +1 -1
  8. {dbhydra-2.2.13 → dbhydra-2.2.16}/LICENSE +0 -0
  9. {dbhydra-2.2.13 → dbhydra-2.2.16}/README.md +0 -0
  10. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/__init__.py +0 -0
  11. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/dbhydra_core.py +0 -0
  12. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/src/__init__.py +0 -0
  13. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/src/bigquery_db.py +0 -0
  14. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/src/errors/__init__.py +0 -0
  15. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/src/errors/exceptions.py +0 -0
  16. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/src/migrator.py +0 -0
  17. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/src/mongo_db.py +0 -0
  18. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/src/postgres_db.py +0 -0
  19. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/src/sqlserver_db.py +0 -0
  20. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/src/xlsx_db.py +0 -0
  21. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/test_migrator.py +0 -0
  22. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/tests/__init__.py +0 -0
  23. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/tests/test_cases.py +0 -0
  24. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/tests/test_mongo.py +0 -0
  25. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra/tests/test_sql.py +0 -0
  26. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra.egg-info/SOURCES.txt +0 -0
  27. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra.egg-info/dependency_links.txt +0 -0
  28. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra.egg-info/requires.txt +0 -0
  29. {dbhydra-2.2.13 → dbhydra-2.2.16}/dbhydra.egg-info/top_level.txt +0 -0
  30. {dbhydra-2.2.13 → dbhydra-2.2.16}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbhydra
3
- Version: 2.2.13
3
+ Version: 2.2.16
4
4
  Summary: Data science friendly ORM combining Python
5
5
  Home-page: https://github.com/DovaX/dbhydra
6
6
  Author: DovaX
@@ -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, debug_mode=False):
76
+ def __init__(self, config_file="config.ini", db_details=None, debug_mode=False, debug_message=""):
77
77
  if db_details is None:
78
78
  db_details = read_connection_details(config_file)
79
79
 
@@ -88,6 +88,7 @@ class AbstractDb(abc.ABC):
88
88
 
89
89
  self.is_autocommiting=True
90
90
  self.debug_mode = debug_mode
91
+ self.debug_message = debug_message
91
92
 
92
93
  if "DB_PORT" in db_details.keys():
93
94
  self.DB_PORT = int(db_details["DB_PORT"])
@@ -156,13 +157,13 @@ class AbstractDb(abc.ABC):
156
157
  try:
157
158
  if self.debug_mode:
158
159
  with open("dbhydra_logs.txt","a+") as file:
159
- file.write(str(datetime.datetime.now())+": DB "+str(self)+": _connect() called\n")
160
+ file.write(str(datetime.datetime.now())+": DB "+str(self)+": _connect() called, debug msg:"+str(self.debug_message)+"\n")
160
161
  self._connect()
161
162
  yield None
162
163
  finally:
163
164
  if self.debug_mode:
164
165
  with open("dbhydra_logs.txt","a+") as file:
165
- file.write(str(datetime.datetime.now())+": DB "+str(self)+": close_connection() called\n")
166
+ file.write(str(datetime.datetime.now())+": DB "+str(self)+": close_connection() called, debug msg:"+str(self.debug_message)+"\n")
166
167
  self.close_connection()
167
168
 
168
169
  @contextmanager
@@ -197,7 +198,7 @@ class AbstractDb(abc.ABC):
197
198
  self.cursor.commit()
198
199
  if self.debug_mode:
199
200
  with open("dbhydra_logs.txt","a+") as file:
200
- file.write(str(datetime.datetime.now())+": DB "+str(self)+": execute() called\n")
201
+ file.write(str(datetime.datetime.now())+": DB "+str(self)+": execute() called, debug msg:"+str(self.debug_message)+"\n")
201
202
  with open("dbhydra_queries_logs.txt","a+") as file:
202
203
  file.write(str(datetime.datetime.now())+": "+str(query)+"\n")
203
204
  return(result)
@@ -424,14 +424,26 @@ class AbstractTable(AbstractJoinable, abc.ABC):
424
424
 
425
425
  #TODO: need to solve inserting in different column_order
426
426
  #check df column names, permute if needed
427
- def insert_from_column_value_dict(self, dict, insert_id=False):
428
- df = pd.DataFrame(dict, index=[0])
427
+ def insert_from_column_value_dict(self, inserted_dict, insert_id=False):
428
+ print("DbHydra deprecation warning! insert_from_column_value_dict method was renamed to insert_from_dict and will be deprecated.")
429
+ self.insert_from_dict(inserted_dict, insert_id)
430
+
431
+ def insert_from_column_value_dict_list(self, inserted_list, insert_id=False):
432
+ print("DbHydra deprecation warning! insert_from_column_value_dict_list method was renamed to insert_from_dict_list and will be deprecated.")
433
+ self.insert_from_dict(inserted_list, insert_id)
434
+
435
+ def insert_from_dict(self, column_value_dict, insert_id = False):
436
+ df = pd.DataFrame(column_value_dict, index=[0])
429
437
  return self.insert_from_df(df, insert_id=insert_id)
430
438
 
431
- def insert_from_column_value_dict_list(self, list, insert_id=False):
432
- df = pd.DataFrame(list)
433
- self.insert_from_df(df, insert_id=insert_id)
434
-
439
+ def insert_from_dict_list(self, column_value_dict_list, insert_id = False):
440
+ df = pd.DataFrame(column_value_dict_list)
441
+ return self.insert_from_df(df, insert_id=insert_id)
442
+
443
+ def update_from_dict(self, column_value_dict, where_column: Optional[str] = None, where_value: Any = None):
444
+ update_df = pd.DataFrame(column_value_dict, index=[0])
445
+ self.update_from_df(update_df, where_column, where_value)
446
+
435
447
 
436
448
  def delete(self, where=None):
437
449
  quote = self.db1.identifier_quote
@@ -57,7 +57,7 @@ class MysqlDb(AbstractDb):
57
57
  self.connection.commit()
58
58
  if self.debug_mode:
59
59
  with open("dbhydra_logs.txt","a+") as file:
60
- file.write(str(datetime.datetime.now())+": DB "+str(self)+": execute() called\n")
60
+ file.write(str(datetime.datetime.now())+": DB "+str(self)+": execute() called, debug msg:"+str(self.debug_message)+"\n")
61
61
  with open("dbhydra_queries_logs.txt","a+") as file:
62
62
  file.write(str(datetime.datetime.now())+": "+str(query)+"\n")
63
63
  return result
@@ -809,7 +809,7 @@ class MysqlTable(AbstractTable):
809
809
  elif 'blob' in self.types[j + start_index]:
810
810
  # Convert to hex to allow insertion into SQL query
811
811
  hex_data = binascii.hexlify(rows[k][j]).decode('ascii')
812
- query += f"UNHEX('{hex_data}'), "
812
+ query += f"UNHEX('{hex_data}'),"
813
813
 
814
814
  else:
815
815
  query += str(rows[k][j]) + ","
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbhydra
3
- Version: 2.2.13
3
+ Version: 2.2.16
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='2.2.13',
8
+ version='2.2.16',
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