Migration to SQLite

This commit is contained in:
jndaniels 2024-10-30 21:51:39 -05:00
parent 9137a379ce
commit 461e52d323
13 changed files with 263 additions and 103 deletions

View File

@ -1,13 +1,12 @@
{
"name": "ERTdb",
"name": "DB",
"module": "dbconnector",
"action": "connect",
"options": {
"client": "sqlite3",
"connection": {
"filename": "/ERTSQlite.db"
"filename": "/public/ERTSQlite.db"
},
"tz": "utc"
},
"fileName": "ERTdb.json"
}
}

View File

@ -1,17 +1,20 @@
{
"type": "sqlite3",
"connection": {
"filename": "/ERTSQlite.db"
"filename": "/public/ERTSQlite.db"
},
"direct": true,
"schema": {
"tables": {
"_da_old_20241029": {
"db": {}
},
"da": {
"db": {},
"columns": {
"ID": {
"db": {
"type": "integer",
"type": "increments",
"primary": true,
"unique": false,
"nullable": false

Binary file not shown.

View File

@ -1,3 +0,0 @@
{
"exec": {}
}

60
app/api/delRecord.json Normal file
View File

@ -0,0 +1,60 @@
{
"meta": {
"$_POST": [
{
"type": "text",
"name": "deleteid"
}
]
},
"exec": {
"steps": {
"name": "delete",
"module": "dbupdater",
"action": "delete",
"options": {
"connection": "DB",
"sql": {
"type": "delete",
"table": "da",
"wheres": {
"condition": "AND",
"rules": [
{
"id": "ID",
"field": "ID",
"type": "double",
"operator": "equal",
"value": "{{$_POST.deleteid}}",
"data": {
"column": "ID"
},
"operation": "="
}
],
"conditional": null,
"valid": true
},
"returning": "ID",
"query": "delete from `da` where `ID` = ?",
"params": [
{
"operator": "equal",
"type": "expression",
"name": ":P1",
"value": "{{$_POST.deleteid}}",
"test": ""
}
]
}
},
"meta": [
{
"name": "affected",
"type": "number"
}
],
"output": true
}
}
}

116
app/api/insert.json Normal file
View File

@ -0,0 +1,116 @@
{
"meta": {
"$_POST": [
{
"type": "text",
"name": "db_fullName"
},
{
"type": "text",
"name": "db_licenseNumber"
},
{
"type": "text",
"name": "db_stateIssue"
},
{
"type": "number",
"name": "db_employeeID"
},
{
"type": "text",
"name": "owner"
}
]
},
"exec": {
"steps": {
"name": "insert",
"module": "dbupdater",
"action": "insert",
"options": {
"connection": "DB",
"sql": {
"type": "insert",
"values": [
{
"table": "da",
"column": "db_fullName",
"type": "text",
"value": "{{$_POST.db_fullName}}"
},
{
"table": "da",
"column": "db_licenseNumber",
"type": "text",
"value": "{{$_POST.db_licenseNumber}}"
},
{
"table": "da",
"column": "db_stateIssue",
"type": "text",
"value": "{{$_POST.db_stateIssue}}"
},
{
"table": "da",
"column": "db_employeeID",
"type": "number",
"value": "{{$_POST.db_employeeID}}"
},
{
"table": "da",
"column": "owner",
"type": "text",
"value": "{{$_POST.owner}}"
}
],
"table": "da",
"returning": "ID",
"query": "insert into `da` (`db_employeeID`, `db_fullName`, `db_licenseNumber`, `db_stateIssue`, `owner`) values (?, ?, ?, ?, ?) returning `ID`",
"params": [
{
"name": ":P1",
"type": "expression",
"value": "{{$_POST.db_fullName}}",
"test": ""
},
{
"name": ":P2",
"type": "expression",
"value": "{{$_POST.db_licenseNumber}}",
"test": ""
},
{
"name": ":P3",
"type": "expression",
"value": "{{$_POST.db_stateIssue}}",
"test": ""
},
{
"name": ":P4",
"type": "expression",
"value": "{{$_POST.db_employeeID}}",
"test": ""
},
{
"name": ":P5",
"type": "expression",
"value": "{{$_POST.owner}}",
"test": ""
}
]
}
},
"meta": [
{
"name": "identity",
"type": "text"
},
{
"name": "affected",
"type": "number"
}
]
}
}
}

View File

@ -17,7 +17,7 @@
"module": "dbconnector",
"action": "select",
"options": {
"connection": "ERTdb",
"connection": "DB",
"sql": {
"type": "select",
"columns": [],
@ -27,7 +27,6 @@
},
"primary": "ID",
"joins": [],
"orders": [],
"query": "select * from `da`"
}
},

View File

@ -1,13 +1,12 @@
{
"name": "ERTdb",
"name": "DB",
"module": "dbconnector",
"action": "connect",
"options": {
"client": "sqlite3",
"connection": {
"filename": "/ERTSQlite.db"
"filename": "/public/ERTSQlite.db"
},
"tz": "utc"
},
"fileName": "ERTdb.json"
}
}

BIN
public/ERTSQlite.db Normal file

Binary file not shown.

View File

@ -1,44 +0,0 @@
dmx.config({
"main": {
"datastore1": [
{
"type": "boolean",
"name": "dirty"
}
]
},
"index": {
"datastore1": [
{
"type": "text",
"name": "da_fullName"
},
{
"type": "text",
"name": "da_driverLicense"
},
{
"type": "text",
"name": "da_driverLicenseState"
}
],
"dataID": {
"outputType": "text"
},
"DSflow1": {
"meta": {},
"local": [
{
"name": "DSConfirm",
"type": "boolean",
"metaData": {
"confirmMessage": {
"meta": null,
"outputType": "text"
}
}
}
]
}
}
});

11
public/trainer.json Normal file
View File

@ -0,0 +1,11 @@
{
"Trainer": {
"Jeff": {},
"Amy": {},
"Justin": {},
"Teresa": {},
"Angie": {},
"Valerie": {},
"Pree": {}
}
}

View File

@ -1,5 +1,7 @@
<!-- Wappler include head-page="layouts/main" fontawesome_5="cdn" bootstrap5="local" is="dmx-app" id="index" appConnect="local" components="{dmxBootstrap5Navigation:{},dmxAnimateCSS:{},dmxStateManagement:{},dmxDatastore:{},dmxBootstrap5Modal:{},dmxFormatter:{},dmxBootstrap5TableGenerator:{},dmxBootstrap5Toasts:{}}" -->
<dmx-serverconnect id="DBSC1" url="/api/dbQuery"></dmx-serverconnect>
<dmx-serverconnect id="DBInsert" url="/api/insert" noload="true"></dmx-serverconnect>
<div is="dmx-bs5-toasts" id="toasts1"></div>
<dmx-serverconnect id="DBSC1" url="/api/query"></dmx-serverconnect>
<script is="dmx-flow" id="DSflow1" type="text/dmx-flow">{
confirm: {
name: "DSConfirm",
@ -14,7 +16,7 @@
}</script>
<dmx-value id="dataID"></dmx-value>
<dmx-json-datasource id="stateJSON" is="dmx-serverconnect" url="/states.json"></dmx-json-datasource>
<dmx-datastore id="datastore1"></dmx-datastore>
<dmx-json-datasource id="trainerJSON" is="dmx-serverconnect" url="/trainer.json"></dmx-json-datasource>
<div class="modal" id="modal1" is="dmx-bs5-modal" tabindex="-1">
<div class="modal-dialog" role="document">
<div class="modal-content">
@ -24,34 +26,46 @@
</div>
<div class="modal-body">
<div class="container">
<form id="form1">
<form is="dmx-serverconnect-form" id="serverconnectform1" method="post" action="/api/insert" dmx-generator="bootstrap5" dmx-form-type="horizontal" dmx-on:done="modal1.hide()">
<div class="form-group mb-3 row">
<label for="input1" class="col-sm-2 col-form-label">Full Name</label>
<label for="inp_db_fullName" class="col-sm-2 col-form-label">full name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="input1" name="input1" aria-describedby="input1_help">
<small id="input1_help" class="form-text text-muted">*Enter your full name</small>
<input type="text" class="form-control" id="inp_db_fullName" name="db_fullName" aria-describedby="inp_db_fullName_help" placeholder="Enter Db full name">
</div>
</div>
<div class="form-group mb-3 row">
<label for="input2" class="col-sm-2 col-form-label">License no.</label>
<label for="inp_db_licenseNumber" class="col-sm-2 col-form-label">license number</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="input2" name="input2" aria-describedby="input1_help">
<small id="input1_help1" class="form-text text-muted">*Enter your driver license number</small>
<input type="text" class="form-control" id="inp_db_licenseNumber" name="db_licenseNumber" aria-describedby="inp_db_licenseNumber_help" placeholder="Enter Db license number">
</div>
</div>
<div class="form-group mb-3 row">
<label for="input3" class="col-sm-2 col-form-label">License State</label>
<div class="col">
<div class="form-group mb-3">
<label for="input3" class="form-label">Select</label>
<select id="input3" class="form-select" dmx-bind:options="stateJSON.data.states" optiontext="name" optionvalue="abbreviation">
<label for="inp_db_stateIssue" class="col-sm-2 col-form-label">state issue</label>
<div class="col-sm-10">
<select id="select1" class="form-select" dmx-bind:options="stateJSON.data.states" optiontext="name" optionvalue="abbreviation">
<option value="1">Option One</option>
<option value="2">Option Two</option>
<option value="3">Option Three</option>
</select>
<small id="select1Help" class="form-text text-muted">Pick the state your License is issued from</small>
</div>
</div>
<div class="form-group mb-3 row">
<label for="inp_db_employeeID" class="col-sm-2 col-form-label">Trainer</label>
<div class="col-sm-10">
<input type="number" class="form-control" id="inp_db_employeeID" name="db_employeeID" aria-describedby="inp_db_employeeID_help" placeholder="Enter Db employee">
</div>
</div>
<div class="form-group mb-3 row">
<label for="inp_owner" class="col-sm-2 col-form-label">Owner</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inp_owner" name="owner" aria-describedby="inp_owner_help" placeholder="Enter Owner">
</div>
</div>
<div class="form-group mb-3 row">
<div class="col-sm-2">&nbsp;</div>
<div class="col-sm-10">
<button type="submit" class="btn btn-primary" dmx-bind:disabled="state.executing">Save <span class="spinner-border spinner-border-sm" role="status" dmx-show="state.executing"></span></button>
</div>
</div>
</form>
</div>
@ -59,7 +73,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" dmx-on:click="datastore1.insert({da_fullName: form1.input1.value, da_driverLicense: form1.input2.value, da_driverLicenseState: form1.input3.selectedValue})">Save changes</button>
<button type="button" class="btn btn-primary" data-bs-toggle="button">Save changes</button>
</div>
</div>
</div>
@ -78,30 +92,37 @@
</div>
</div>
<div class="row" dmx-hide="datastore1.data.isEmpty()">
<table class="table table-striped table-sm">
</div>
<table class="table">
<thead>
<tr>
<th>$id</th>
<th>Da full name</th>
<th>Da driver license</th>
<th dmx-on:click="datastore1.clear()">Da driver license state</th>
<th>Id</th>
<th>Db full name</th>
<th>Db license number</th>
<th>Db state issue</th>
<th>Db employee</th>
<th>Owner</th>
</tr>
</thead>
<tbody is="dmx-repeat" dmx-generator="bs5table" dmx-bind:repeat="datastore1.data" id="tableRepeat1">
<tbody is="dmx-repeat" dmx-generator="bs5table" dmx-bind:repeat="DBSC1.data.query" id="tableRepeat1">
<tr>
<td>
<button id="btn3" class="btn btn-sm btn-warning" dmx-bind:value="$id" dmx-on:click="datastore1.delete({$id: $id})" data-bs-toggle="button">{{$id}}</button>
<form id="IDAction" action="/api/delRecord" method="post" is="dmx-serverconnect-form" dmx-on:success="DBSC1.load({})">
<input id="deleteid" name="deleteid" type="hidden" class="form-control" dmx-bind:value="ID">
<button id="btn3" class="btn btn-sm btn-warning" dmx-text="ID" type="submit" dmx-on:click="btn3.setValue(ID)">Button</button>
</form>
</td>
<td dmx-text="da_fullName"></td>
<td dmx-text="da_driverLicense"></td>
<td dmx-text="da_driverLicenseState"></td>
<td dmx-text="db_fullName"></td>
<td dmx-text="db_licenseNumber"></td>
<td dmx-text="db_stateIssue"></td>
<td dmx-text="db_employeeID"></td>
<td dmx-text="owner"></td>
</tr>
</tbody>
</table>
</div>
<div class="row">
<h3 dmx-show="datastore1.data.isEmpty()">No Records</h3>
<h3>{{DBSC1.data.query.count()+" Records"}}</h3>
</div>
</div>

View File

@ -24,7 +24,6 @@
</head>
<body is="dmx-app" id="main">
<dmx-datastore id="datastore1"></dmx-datastore>
<div class="container">
<nav class="navbar navbar-expand-lg">
<div class="navbar-nav w-100">