-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab_12_log_module.py
More file actions
executable file
·38 lines (31 loc) · 951 Bytes
/
Copy pathlab_12_log_module.py
File metadata and controls
executable file
·38 lines (31 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/python
import sqlite3
class LogMessageDB:
def __init__(self,database):
self.database = database
self.db = sqlite3.connect(self.database)
self.db.execute('create table if not exists LogMessage(error_message text)')
self.db.commit()
self.db.close()
def read(self):
self.db = sqlite3.connect(self.database)
input = self.db.execute('select * from LogMessage')
for line in input:
print(line)
self.db.close()
def write(self,error):
self.db = sqlite3.connect(self.database)
self.db.execute('insert into LogMessage (error_message)values(?)', (error,))
self.db.commit()
self.db.close()
class LogMessageFile:
def __init__(self,filename):
self.filename = filename
def read(self):
input = open(self.filename, 'r')
for line in input:
print(line)
#print(line, end='')
def write(self,error):
output = open(self.filename, 'a')
output.write(error)