diff options
author | JoelHMikael <53561102+JoelHMikael@users.noreply.github.com> | 2022-01-18 18:57:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-18 18:57:53 +0200 |
commit | a259127b9fa0349c73340c882f6525f27f7caaed (patch) | |
tree | ad18984d3031ce6bc7ccb549415c58d77672a53f /update.js | |
parent | 8f711465194f6779271825bdb2413658880f4c18 (diff) | |
parent | edf044c1e1e0c751229549dd9d14062b230149be (diff) | |
download | LYLLRuoka-a259127b9fa0349c73340c882f6525f27f7caaed.tar.gz LYLLRuoka-a259127b9fa0349c73340c882f6525f27f7caaed.zip |
Merge pull request #1 from JoelHMikael/MYSQLDB
Mysqldb
Diffstat (limited to 'update.js')
-rw-r--r-- | update.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/update.js b/update.js new file mode 100644 index 0000000..9262ff7 --- /dev/null +++ b/update.js @@ -0,0 +1,21 @@ +const database = require("./database.js"); +const openFile = require("./open.js").file; +const parseClasses = require("./parseClasses.js").classes; +const parse = require("./dbparse.js"); + +// Run this if you want to build the database from text files +async function buildDB(shiftfile = "./shifts.txt", classfile = "./classes.txt", dbcredentials) +{ + let shiftCont = await openFile(shiftfile); + const DB = new database.Database(JSON.parse(dbcredentials)); + shiftCont = shiftCont.toString("utf-8").replaceAll("\r", ""); // \r because of the \r\n newline on windows which creates problems + await Promise.all([ + parseClasses(classfile[0], classfile[1], DB), + parse.build(shiftCont, DB) + ]); + return 0; +} + +exports.update = buildDB; +// Example call: +// await updateDB.update("./shifts.txt", ["./Kurssitarjottimet/2016Classes.txt", "./Kurssitarjottimet/NewClasses.txt"], dbcredentials);
\ No newline at end of file |