瀏覽代碼

filename specification for running as a service

tags/v1.0.0
Dirk Alders 2 年之前
父節點
當前提交
34800bf5d9
共有 1 個檔案被更改,包括 4 行新增1 行删除
  1. 4
    1
      function/db.py

+ 4
- 1
function/db.py 查看文件

@@ -1,5 +1,8 @@
1
+import os
1 2
 import sqlite3
2 3
 
4
+db_file = os.path.join(os.path.dirname(__file__), '..', 'database.db')
5
+
3 6
 
4 7
 def get_gui_radiator_data(topic):
5 8
     return __storage__().get_gui_radiator_data(topic)
@@ -11,7 +14,7 @@ def set_gui_radiator_data(topic, away_mode, summer_mode, user_temperatur_setpoin
11 14
 
12 15
 class __storage__(object):
13 16
     def __init__(self):
14
-        self.conn = sqlite3.connect("database.db")
17
+        self.conn = sqlite3.connect(db_file)
15 18
         self.c = self.conn.cursor()
16 19
         with self.conn:
17 20
             self.c.execute("""CREATE TABLE IF NOT EXISTS gui_radiator (

Loading…
取消
儲存