Browse Source

filename specification for running as a service

tags/v1.0.0
Dirk Alders 2 years ago
parent
commit
34800bf5d9
1 changed files with 4 additions and 1 deletions
  1. 4
    1
      function/db.py

+ 4
- 1
function/db.py View File

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

Loading…
Cancel
Save