trying to persist the db

This commit is contained in:
Martin Donnelly 2015-11-09 11:11:14 +00:00
parent 29a6bd4d9a
commit f28b4d58ec
2 changed files with 51 additions and 16 deletions

View File

@ -1,14 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="8a985735-5aff-47ce-a55f-2957d4f9c5f9" name="Default" comment=""> <list default="true" id="8a985735-5aff-47ce-a55f-2957d4f9c5f9" name="Default" comment="Initial Commit&#10;">
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/codeStyleSettings.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/routes/btc.js" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/routes/temp.js" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/misc.xml" afterPath="$PROJECT_DIR$/.idea/misc.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/app.js" afterPath="$PROJECT_DIR$/app.js" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/routes/temp.js" afterPath="$PROJECT_DIR$/routes/temp.js" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/package.json" afterPath="$PROJECT_DIR$/package.json" />
</list> </list>
<ignored path="silvrapi.iws" /> <ignored path="silvrapi.iws" />
<ignored path=".idea/workspace.xml" /> <ignored path=".idea/workspace.xml" />
@ -34,7 +29,11 @@
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-0.0"> <state vertical-scroll-proportion="-0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding /> <folding>
<marker date="1447026540000" expanded="true" signature="0:378" placeholder="{&quot;name&quot;: &quot;silvrapi&quot;...}" />
<marker date="1447026540000" expanded="true" signature="78:113" placeholder="{&quot;start&quot;: &quot;node ./bin/www&quot;...}" />
<marker date="1447026540000" expanded="true" signature="133:323" placeholder="{&quot;body-parser&quot;: &quot;~1.13.2&quot;...}" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
@ -92,8 +91,8 @@
<file leaf-file-name="temp.js" pinned="false" current-in-tab="true"> <file leaf-file-name="temp.js" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/routes/temp.js"> <entry file="file://$PROJECT_DIR$/routes/temp.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.6858974"> <state vertical-scroll-proportion="-0.024038462">
<caret line="46" column="3" selection-start-line="46" selection-start-column="3" selection-end-line="46" selection-end-column="3" /> <caret line="8" column="17" selection-start-line="8" selection-start-column="17" selection-end-line="8" selection-end-column="17" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -338,7 +337,25 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1447023017687</updated> <updated>1447023017687</updated>
</task> </task>
<option name="localTasksCounter" value="2" /> <task id="LOCAL-00002" summary="Initial Commit&#10;">
<created>1447030070358</created>
<option name="number" value="00002" />
<option name="project" value="LOCAL" />
<updated>1447030070358</updated>
</task>
<task id="LOCAL-00003" summary="debugging">
<created>1447055263421</created>
<option name="number" value="00003" />
<option name="project" value="LOCAL" />
<updated>1447055263421</updated>
</task>
<task id="LOCAL-00004" summary="closing db to persist&#10;">
<created>1447056652943</created>
<option name="number" value="00004" />
<option name="project" value="LOCAL" />
<updated>1447056652943</updated>
</task>
<option name="localTasksCounter" value="5" />
<servers /> <servers />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
@ -370,8 +387,13 @@
<option name="myLimit" value="2678400000" /> <option name="myLimit" value="2678400000" />
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
<option name="CHECK_CODE_CLEANUP_BEFORE_PROJECT_COMMIT" value="true" />
<option name="CHECK_NEW_TODO" value="false" />
<MESSAGE value="Initial Commit&#10;" /> <MESSAGE value="Initial Commit&#10;" />
<option name="LAST_COMMIT_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;" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager /> <breakpoint-manager />
@ -382,7 +404,11 @@
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0"> <state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding /> <folding>
<marker date="1447026540000" expanded="true" signature="0:378" placeholder="{&quot;name&quot;: &quot;silvrapi&quot;...}" />
<marker date="1447026540000" expanded="true" signature="78:113" placeholder="{&quot;start&quot;: &quot;node ./bin/www&quot;...}" />
<marker date="1447026540000" expanded="true" signature="133:323" placeholder="{&quot;body-parser&quot;: &quot;~1.13.2&quot;...}" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
@ -444,8 +470,8 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/routes/temp.js"> <entry file="file://$PROJECT_DIR$/routes/temp.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.6858974"> <state vertical-scroll-proportion="-0.024038462">
<caret line="46" column="3" selection-start-line="46" selection-start-column="3" selection-end-line="46" selection-end-column="3" /> <caret line="8" column="17" selection-start-line="8" selection-start-column="17" selection-end-line="8" selection-end-column="17" />
<folding /> <folding />
</state> </state>
</provider> </provider>

View File

@ -1,11 +1,20 @@
var express = require('express'), sqlite3 = require('sqlite3').verbose(); var express = require('express'), fs = require('fs'), sqlite3 = require('sqlite3').verbose();
var router = express.Router(); var router = express.Router();
var temp_db; var temp_db;
var file = "temp.sqlite3";
var exists;
/* GET users listing. */ /* GET users listing. */
function createDB() { function createDB() {
console.log('Creating Temp db...'); console.log('Creating Temp db...');
if (!fs.existsSync(file)) {
console.log('creating db file');
fs.openSync(file,'w');
}
temp_db = new sqlite3.Database('temp.sqlite3', createTable); temp_db = new sqlite3.Database('temp.sqlite3', createTable);
} }