Browse Source

[db] close connection after executing query

Maxime Alves LIRMM@home 3 years ago
parent
commit
27f41a631c
1 changed files with 4 additions and 2 deletions
  1. 4
    2
      pyheatpump/db.py

+ 4
- 2
pyheatpump/db.py View File

@@ -13,8 +13,8 @@ conn = None
13 13
 def connect():
14 14
     global conn
15 15
     if conn is None:
16
-        # logger.info('Will connect to database {}'.format(
17
-        #    config['heatpump']['database']))
16
+        logger.info('Will connect to database {}'.format(
17
+           config['heatpump']['database']))
18 18
         conn = sqlite3.connect(config['heatpump']['database'])
19 19
         conn.row_factory = sqlite3.Row
20 20
     return conn
@@ -40,6 +40,8 @@ def sql(query):
40 40
     logger.debug(f'Will execute query : \n{query}\n')
41 41
     cursor.execute(query)
42 42
 
43
+    conn.close()
44
+    logger.debug(f'Connection closed\n')
43 45
     return cursor
44 46
 
45 47
 class RowClass(object):

Loading…
Cancel
Save