Browse Source

[logs] added debug logging to db

Maxime Alves LIRMM@home 3 years ago
parent
commit
4411093650
1 changed files with 5 additions and 3 deletions
  1. 5
    3
      pyheatpump/db.py

+ 5
- 3
pyheatpump/db.py View File

@@ -5,12 +5,15 @@ from .conf import config
5 5
 import sys
6 6
 from pprint import pprint
7 7
 
8
+from pyheatpump.logger import logger_init
9
+logger = logger_init()
10
+
8 11
 conn = None
9 12
 
10 13
 def connect():
11 14
     global conn
12 15
     if conn is None:
13
-        print('Will connect to database {}'.format(
16
+        logger.info('Will connect to database {}'.format(
14 17
             config['heatpump']['database']))
15 18
         conn = sqlite3.connect(config['heatpump']['database'])
16 19
         conn.row_factory = sqlite3.Row
@@ -29,9 +32,8 @@ def sql(query):
29 32
     if conn is None:
30 33
         connect()
31 34
 
32
-    pprint(conn)
33 35
     cursor = conn.cursor()
34
-    print(f'Will execute query : \n{query}\n')
36
+    logger.debug(f'Will execute query : \n{query}\n')
35 37
     cursor.execute(query)
36 38
 
37 39
     return cursor

Loading…
Cancel
Save