I am setting up a database with customer data in SQLite 3.2.1 using Node.js in Javascript.
The error SQLITE_ERROR: no such table: T_KUNDENDATEN_DE keeps being returned. From the error I understand that the DB can be contacted. The SQL Query works and the variables vorname and nachname are correctly captured in the URL and passed to the db.all constructor. But it return the error. In debug-mode I cannot figure out what is going wrong here.
The table T_KUNDENDATEN_DE is not new and has data in it.
Any suggestions to resolve this issue?
URL used to call app.get('/cdata'.
http://localhost:8000/cdata?vorname=ralf&nachname=ruf
// Create express app
var express = require("express")
var app = express()
var DateObj= new Date()
var sqlite3 = require('sqlite3');
var db = new sqlite3.Database('KundendatenJS.db');
// Server port
var HTTP_PORT = 8000
// Start server
app.listen(HTTP_PORT, () => {
console.log("Server running on port %PORT%".replace("%PORT%",HTTP_PORT))
});
// Root endpoint
app.get("/", (req, res, next) => {
res.json({"message":"Ok" + " " + DateObj })
});
// API endpoints
app.get('/cdata', function(req, res){
if(req.query.vorname && req.query.nachname){
db.all('SELECT * FROM T_KUNDENDATEN_DE WHERE UPPER(VORNAME) = UPPER(?) AND UPPER(NACHNAME)=UPPER(?)', [req.query.vorname,req.query.nachname], function(err, rows){
if(err){
res.send(err.message);
}
else{
console.log("Return the customer data for: " + req.query.vorname + " " + req.query.nachname);
res.json(rows);
}
});
}
else{
console.log("No data found")
}
});
// Default response for any other request
app.use(function(req, res){
res.status(404);
});```
T_KUNDENDATEN_DEviamysql?mysql -u root -p-> password ->use MyDATABASE; describe T_KUNDENDATEN_DE;