Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 35:0f01042765d6, committed 2017-01-17
- Comitter:
- Jan Kopa?ski
- Date:
- Tue Jan 17 11:50:16 2017 +0100
- Parent:
- 34:e67581c9b50d
- Child:
- 36:6686483418a4
- Commit message:
- server timestamp
Changed in this revision
--- a/server/databaseconnector.py Tue Jan 17 11:44:16 2017 +0100
+++ b/server/databaseconnector.py Tue Jan 17 11:50:16 2017 +0100
@@ -1,5 +1,6 @@
from sqlite3 import connect, Error
from threading import Lock
+from datetime import datetime
json_template = {
'sensors': [
@@ -43,6 +44,7 @@
if not data:
return 'Request message is empty'
vals = data.split(self.separator)
+ vals += [datetime.now()]
stmt = ("INSERT INTO %s VALUES (NULL" + (", ?" * len(vals)) + ")") % table
self.mutex.acquire()
try:
--- a/server/kubus.sql Tue Jan 17 11:44:16 2017 +0100 +++ b/server/kubus.sql Tue Jan 17 11:50:16 2017 +0100 @@ -1,19 +1,23 @@ CREATE TABLE pir1 ( id INTEGER PRIMARY KEY, - value INTEGER NOT NULL + value INTEGER NOT NULL, + timestamp DATE ); CREATE TABLE pir2 ( id INTEGER PRIMARY KEY, - value INTEGER NOT NULL + value INTEGER NOT NULL, + timestamp DATE ); CREATE TABLE distance ( id INTEGER PRIMARY KEY, - value REAL NOT NULL + value REAL NOT NULL, + timestamp DATE ); CREATE TABLE volume ( id INTEGER PRIMARY KEY, - value REAL NOT NULL + value REAL NOT NULL, + timestamp DATE ); \ No newline at end of file
--- a/server/server.py Tue Jan 17 11:44:16 2017 +0100 +++ b/server/server.py Tue Jan 17 11:50:16 2017 +0100 @@ -8,8 +8,10 @@ host = '46.101.12.31' +# host = "localhost" coapport = 4242 database = '/home/jan/server/kubus.db' +# database = "kubus.db" tables = ['pir1', 'pir2', 'distance', 'volume'] connector = DatabaseConnector(database=database, tables=tables)