Titanium: Uncaught Error: no such table - database

Database has been installed but can't access
I have kwf.db3 file in "/app" folder
In /app/controllers/search.js file:
I have installed kwf by script: var db = Ti.Database.install('../kwf.db3', 'keywords');
To confirm success, I have read "keywords" Database by script:
var text;
var openMyFile = Titanium.Filesystem.getFile("file://data/data/"+ Ti.App.getId()+"/databases/keywords");
if(openMyFile.exists())
{text = openMyFile.read().toString();}
"text" has retrieved keywords content. => Successful Installing.
BUTTTT
When I excute SELECT query,
var db = Ti.Database.open('keywords');
var searchKeyWords = db.execute("SELECT SearchText from SearchKeyWords WHERE SearchText LIKE '%bay%' ORDER BY Length(SearchText) ASC LIMIT 15");
I got an error (Uncaught error: no such table)
https://dl.dropboxusercontent.com/u/50234898/kwf_err.png
I had ran this query in SQLite Manager but I got no error
https://dl.dropboxusercontent.com/u/50234898/kwf_exc.png
Help me, please!!!
Thanks!

first and for most, you need to close database connection after installation of database.
then to confirm that database is installed or not , you should use ddms.
and for android we generally add /(slash) before path so try to do install it by following line..
var db = Ti.Database.install('/../kwf.db3', 'keywords');
db.close();

Related

Cannot add Firebase library to Apps Script

I want to sync a Google Sheet with my Firebase real-time database.
My code is:
function writeDataToFirebase() {
var ss =
SpreadsheetApp.openById("18AU9ZP9UHs9lvIeTA0SyJv6tcHPe7ux0tLopkRAz1T0");
var sheet = ss.getSheets()[0];
var data = sheet.getDataRange().getValues();
var dataToImport = {};
for(var i = 2; i < data.length; i++) {
var date = data[i][1];
dataToImport[date] = {
niftyclose:data[i][2],
sensexclose:data[i][5]
};
}
var firebaseUrl = "<MY database URL>"; //Yes I have entered the URL in my actual code
var base = FirebaseApp.getDatabaseByUrl(firebaseUrl);
base.setData("", dataToImport);
}
But when I run the script, I get this error:
ReferenceError: FirebaseApp is not defined
I tried adding the Firebase Library and got this error:
Firebase Library Error
Can someone help me figure this out?
Thanks in advance.
I think that MYeP8ZEEt1ylVDxS7uyg9plDOcoke7-2l is the project key. In this case, it can be used for the legacy editor. But, in the current stage, the script ID is used for installing the GAS library. And also, when you use new script editor, it is required to use the script ID for installing the library. I thought that this is the reason of your issue.
When the project key of MYeP8ZEEt1ylVDxS7uyg9plDOcoke7-2l is installed using the the legacy editor and check appsscript.json, the script ID of the library can be known. It's 1hguuh4Zx72XVC1Zldm_vTtcUUKUA6iBUOoGnJUWLfqDWx5WlOJHqYkrt. So please modify your situation as follows.
1hguuh4Zx72XVC1Zldm_vTtcUUKUA6iBUOoGnJUWLfqDWx5WlOJHqYkrt
Please install the library using above script ID. This script ID can be also seen at https://sites.google.com/site/scriptsexamples/new-connectors-to-google-services/firebase/source
References:
Libraries
Firebase

Use a .db file with MS Chatbot

Here is my situation : I'm developing a Chatbot on Microsoft azure platform using Node.js. For the moment the bot messages are hard-coded in .json files.
I want to improve it by using calls to a database.
I have a SQLite database file working fine (I used a browser for SQLite and made my requests). But the problem is :
How do can I use my .db file from my project ? Is this possible to somehow "read" the database file from my dialogs and then make my request to get what I need from my database ?
I know that you can call a database with the chatbot, but the issue here is that I only have the file and nothing deployed to call.
Example of what the result should give :
"Hey chatbot, tell me about Mona Lisa"
This triggers the dialogs that will ask the database : "SELECT info FROM arts WHERE arts.title LIKE '%Mona Lisa%' ";
And send the result in session.send(results).
Thanks !
Note : I'm just an intern in my company, the database file is the only thing they gave me and I have to find a solution with it
I got the solution after some research :
First you need to install sqlite3 with npm for example, then use this at the beginning of your code :
var sqlite3 = require('sqlite3').verbose();
var path = require('path');
var db_path = path.resolve(__dirname, name_Of_Your_DB);
And then work on your file with the request you need :
var db = new sqlite3.Database(db_path, sqlite3.OPEN_READONLY,(err) => {
if (err) {
return console.error(err.message);
}
//console.log("Stuff that is processed only if no error happened.");
});
var req = "YOUR REQUEST";
db.get(req, [your_parameter],(err, row) => {
if (err) {
return console.error(err.message);
}
});
db.close((err) => {
if (err) {
return console.log(err.message);
}
});
The documentation about node.js and sqlite3 is quite complete :
http://www.sqlitetutorial.net/sqlite-nodejs/query/

Automated Apps Script for BigQuery Not Connecting To Right Project?

I'm getting the below problem with apps script which is attempting to run a query and create a table, TEST4, in BigQuery. The error is:
"Project 603804914871 is not found and cannot be used for API calls.
(line 19, file "Code")"
Query is:
saveQueryToTable() {
var projectId = 'fiery-cabinet-****';
var datasetId = '11234***1';
var tableId = 'TEST4';
var job = {
configuration: {
query: {
query: 'SELECT *' +
'FROM Test2;',
destinationTable: {
projectId: projectId,
datasetId: datasetId,
tableId: tableId
}
}
}
};
var queryResults = BigQuery.Jobs.insert(job, projectId);
Logger.log(queryResults.status);
}
Could anyone let me know where I'm going wrong?
I can find that project in my console, I can enable the bigquery API for that project and then I don't get any errors... however it doesn't run the query or save to a new table "TEST4"?
Response from #KENDi was correct. I had to enable the API in the Google Developer Console.

CloudKit Database Query Issue

I just started to build a web app, and for some reason I have to use CloudKit and its database for my backend.
I tried a really stupid database query and intended to see the results at frontend. Here is my code :
CloudKit.configure({
containers: [{
containerIdentifier: my identifier,
apiToken: my api token,
environment: 'development'
}]
});
var container = CloudKit.getDefaultContainer();
var DB = container.publicCloudDatabase;
var query = {recordType : 'Request'};
DB.performQuery(query).then(function(response){
if (response.hasErrors) {
throw response.errors[0];
} else {
console.log(response);
}
});
However, I keep getting this authentication_failed error :
cloudkit.js:3 Uncaught (in promise) t {_ckErrorCode: "AUTHENTICATION_FAILED", _uuid: "4ef8ba12-eb00-408f-9a1c-6e8b4de84ec8", _reason: "no auth method found", _serverErrorCode: "AUTHENTICATION_FAILED", _extensionErrorCode: undefined…}
I tried to fetch a record with the same code, and it works fine.
So is the error caused by unlogged in users? If so, Is there any configurations in CloudKit Dashboard to allow users from certain URL to query the database without logging in?
Thanks!
Check the containerIdentifier value. I had a similar issue when I used the identifier name of the API Token instead of the generated iCloud identifier from the app name. You can also verify your token with the link Test with CloudKit Catalog

Access the SQLite db which is externally created

I am creating a hybrid app by telerik app builder in visual studio. I am not able to access sqlite db which is created externally. But I can access the db which is created at run time. I referred some sites, those solutions are not worked for me. The following code will create db and access it while run time
var app = {};
app.db = null;
app.openDb = function () {
var dbName = "Test.sqlite";
//DB creation for Simulator
if (window.navigator.simulator === true) {
app.db = window.openDatabase(dbName, "1.0", "Test Database", 1073741824);
console.log("Database Created!");
}
//DB creation for devices
else {
app.db = window.sqlitePlugin.openDatabase(dbName);
console.log("Database Accessed!");
}
}
I want to access the database which is present in the data folder. Please refer the image.
I tried to place the db in www folder and try to access it by the following code
app.db = window.sqlitePlugin.openDatabase({name: "Test.db", createFromLocation: 1});
It will give the following error
Uncaught TypeError: Cannot read property 'openDatabase' of undefined
So, how can I access the externally created sqlite db?
I included the following scripts in the project
<script src="js/jquery-2.1.0.min.js"></script>
<script src="js/angular.min.js"></script>
<script src="js/ng-cordova.min.js"></script>
It looks like your issue is that window.sqlitePlugin is undefined. Are you sure the plugin is properly installed? Also, you must wait until the deviceReady event before using window.sqlitePlugin.

Resources