dbhydra 2.2.12__py3-none-any.whl → 2.2.14__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.
@@ -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")
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")
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,12 +198,18 @@ 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 with query: "+str(query))
201
+ file.write(str(datetime.datetime.now())+": DB "+str(self)+": execute() called, debug msg:"+str(self.debug_message)+"\n")
202
+ with open("dbhydra_queries_logs.txt","a+") as file:
203
+ file.write(str(datetime.datetime.now())+": "+str(query)+"\n")
201
204
  return(result)
202
205
 
203
206
  def close_connection(self):
204
- self.connection.close()
205
- print("DB connection closed")
207
+ try:
208
+ self.connection.close()
209
+ print("DB connection closed")
210
+ except AttributeError as e:
211
+ raise Exception("DbHydra Error: The connection couldn't be closed, are you sure the connection string to DB is configured correctly? Error message:"+str(e))
212
+
206
213
 
207
214
  def initialize_migrator(self):
208
215
  self.migrator = Migrator(self)
dbhydra/src/mysql_db.py CHANGED
@@ -57,7 +57,9 @@ 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 with query: "+str(query))
60
+ file.write(str(datetime.datetime.now())+": DB "+str(self)+": execute() called, debug msg:"+str(self.debug_message)+"\n")
61
+ with open("dbhydra_queries_logs.txt","a+") as file:
62
+ file.write(str(datetime.datetime.now())+": "+str(query)+"\n")
61
63
  return result
62
64
 
63
65
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbhydra
3
- Version: 2.2.12
3
+ Version: 2.2.14
4
4
  Summary: Data science friendly ORM combining Python
5
5
  Home-page: https://github.com/DovaX/dbhydra
6
6
  Author: DovaX
@@ -2,12 +2,12 @@ dbhydra/__init__.py,sha256=DCocEeXf4QxdVlBRlNiFvuP5IZJ5aa77_DbUR-_4C14,65
2
2
  dbhydra/dbhydra_core.py,sha256=jn0VC3LkawR2P0Yd_oZNEXqP9o2BPEtOBWGzgFwfJyA,2537
3
3
  dbhydra/test_migrator.py,sha256=e3Nnb2mCd3CfjhjSexNg1tXVJMjkl5cCoYcuhbfZ4pM,803
4
4
  dbhydra/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- dbhydra/src/abstract_db.py,sha256=wHJfEeUAI5tJekjrIjDn49-RXADc6g6QChKxlRrLJF8,6616
5
+ dbhydra/src/abstract_db.py,sha256=7Rv2XgdaKiQ5yBnU0EDh5uT8XbB3JI5Pis_in6iHn2c,7172
6
6
  dbhydra/src/abstract_table.py,sha256=VBzK_xMmCdU2QN0jAeQYoXx9vsl73Y7ZZU2YjVuKEN4,18049
7
7
  dbhydra/src/bigquery_db.py,sha256=77XsgvYbANlvYaJnuVve-kz-PNBx_CHoYCL-eYnA8e4,1834
8
8
  dbhydra/src/migrator.py,sha256=QzaODEFfraD9_6HN_Osaidaj-nLYQryCYYWwJtUu3n8,18931
9
9
  dbhydra/src/mongo_db.py,sha256=mP48zRjI7mXKpm45R8prroZI-Eo7JKf0KJqGX-oTy3w,1922
10
- dbhydra/src/mysql_db.py,sha256=jA6n1YjVk7uqAm6guWN-sIWJF4ABfA-9unXrdRcH1Jc,3414
10
+ dbhydra/src/mysql_db.py,sha256=lNWaS3YHtQE1Xii-ErWUDhxeo3b6HWgXxQAMJfgiGEE,3583
11
11
  dbhydra/src/postgres_db.py,sha256=L7MaBq_6ArwDSP_5LaEqK58oLxZ1X7FgIokcDOSB7wk,1805
12
12
  dbhydra/src/sqlserver_db.py,sha256=9Xi3NAliqM79MTV8fpNQb0nWMH8Bqjl1leJSEqgyT94,3611
13
13
  dbhydra/src/tables.py,sha256=v2VxgjKiNQyCdQCuovhpeDklPaqOcPRssTAP0mF2jTw,47613
@@ -18,8 +18,8 @@ dbhydra/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  dbhydra/tests/test_cases.py,sha256=eAFGaHaIaab3md3HHm2_ryb_HHfObtcXDAEzLh4qWx8,508
19
19
  dbhydra/tests/test_mongo.py,sha256=M8TD72M0iQAk7ZcLTWwLmcmmF_zwALnYEGTWjhQlq0s,1979
20
20
  dbhydra/tests/test_sql.py,sha256=aPFXyA0jh8o9VG3B5f9fNz7qDbuVPZ9TcE2twn5dAeQ,3126
21
- dbhydra-2.2.12.dist-info/LICENSE,sha256=k49Yga8CP889JJaHlOpGFzr_be2nqMoep2chYeIDctk,1091
22
- dbhydra-2.2.12.dist-info/METADATA,sha256=iQLUJQBeAEA5w1WCg3-m4kh1Lbj3U3aSRTonOqPaQYs,2299
23
- dbhydra-2.2.12.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
24
- dbhydra-2.2.12.dist-info/top_level.txt,sha256=oO4Gf1T8_txIsIlp11GI0k7PtBIMb9GRwb5ObF4MLVg,8
25
- dbhydra-2.2.12.dist-info/RECORD,,
21
+ dbhydra-2.2.14.dist-info/LICENSE,sha256=k49Yga8CP889JJaHlOpGFzr_be2nqMoep2chYeIDctk,1091
22
+ dbhydra-2.2.14.dist-info/METADATA,sha256=wHpM3ajf_qqriw9t8HZUjAMw4R2R1OjrxZHgHJ9Z2j0,2299
23
+ dbhydra-2.2.14.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
24
+ dbhydra-2.2.14.dist-info/top_level.txt,sha256=oO4Gf1T8_txIsIlp11GI0k7PtBIMb9GRwb5ObF4MLVg,8
25
+ dbhydra-2.2.14.dist-info/RECORD,,