trying to persist the db again

This commit is contained in:
Martin Donnelly 2015-11-09 11:31:24 +00:00
parent f28b4d58ec
commit e2b1283daa
2 changed files with 25 additions and 12 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="8a985735-5aff-47ce-a55f-2957d4f9c5f9" name="Default" comment="Initial Commit&#10;">
<list default="true" id="8a985735-5aff-47ce-a55f-2957d4f9c5f9" name="Default" comment="trying to persist the db">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/routes/temp.js" afterPath="$PROJECT_DIR$/routes/temp.js" />
</list>
@ -91,8 +91,8 @@
<file leaf-file-name="temp.js" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/routes/temp.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-0.024038462">
<caret line="8" column="17" selection-start-line="8" selection-start-column="17" selection-end-line="8" selection-end-column="17" />
<state vertical-scroll-proportion="1.2880921">
<caret line="79" column="11" selection-start-line="79" selection-start-column="11" selection-end-line="79" selection-end-column="11" />
<folding />
</state>
</provider>
@ -355,7 +355,13 @@
<option name="project" value="LOCAL" />
<updated>1447056652943</updated>
</task>
<option name="localTasksCounter" value="5" />
<task id="LOCAL-00005" summary="trying to persist the db">
<created>1447067474637</created>
<option name="number" value="00005" />
<option name="project" value="LOCAL" />
<updated>1447067474637</updated>
</task>
<option name="localTasksCounter" value="6" />
<servers />
</component>
<component name="ToolWindowManager">
@ -367,7 +373,7 @@
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32505175" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.16252588" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="npm" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32919255" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
@ -393,7 +399,8 @@
<MESSAGE value="Initial Commit&#10;" />
<MESSAGE value="debugging" />
<MESSAGE value="closing db to persist&#10;" />
<option name="LAST_COMMIT_MESSAGE" value="closing db to persist&#10;" />
<MESSAGE value="trying to persist the db" />
<option name="LAST_COMMIT_MESSAGE" value="trying to persist the db" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
@ -470,8 +477,8 @@
</entry>
<entry file="file://$PROJECT_DIR$/routes/temp.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-0.024038462">
<caret line="8" column="17" selection-start-line="8" selection-start-column="17" selection-end-line="8" selection-end-column="17" />
<state vertical-scroll-proportion="1.2880921">
<caret line="79" column="11" selection-start-line="79" selection-start-column="11" selection-end-line="79" selection-end-column="11" />
<folding />
</state>
</provider>

View File

@ -2,7 +2,7 @@ var express = require('express'), fs = require('fs'), sqlite3 = require('sqlite3
var router = express.Router();
var temp_db;
var file = "temp.sqlite3";
var file = "/user/martind2000/temp.db";
var exists;
/* GET users listing. */
@ -15,7 +15,13 @@ function createDB() {
}
temp_db = new sqlite3.Database('temp.sqlite3', createTable);
temp_db = new sqlite3.Database(file);
}
function connectDB() {
"use strict";
console.log('Connect db.');
temp_db = new sqlite3.Database(file);
}
function createTable() {
@ -52,7 +58,7 @@ router.get('/', function(req, res, next) {
{
// createDB();
console.log(req.query);
createDB();
connectDB();
insertTempReading(now.toJSON(),parseFloat(req.query.temp) );
@ -71,7 +77,7 @@ router.get('/', function(req, res, next) {
router.get('/all', function(req, res, next) {
"use strict";
console.log('Selecint all..');
createDB();
connectDB();
temp_db.all('SELECT * from temp', function(err, rows) {