Hy, I have an iOS application (only for iOS) developed in Titanium Appcelerator using JavaScript.
I'm trying to use SQLite data bases in my app.
I was able to copy my SQLite database to my project with this:
Ti.Database.install('/baseDados/aquarismo', 'AquaInfo');
This "/baseDados/aquarismo" is the database directory inside my project, and "AquaInfo" is the name of the database after copying it.
Then I can open and close my database to get my data from it.
My problem is when I update my SQLite database I need to update it inside my project. So I replace my database inside my project folder with the new database.
But then I need to delete the old database when my app starts and replace it whit the new one.
I have tried this:
var f = Ti.Filesystem.getFile(
Ti.Filesystem.applicationSupportDirectory, 'database','AquaInfo.sql');
//If it's there, delete it
if(f.exists() == true){
f.deleteFile();
}
// Install fresh database
Ti.Database.install('/baseDados/aquarismo','AquaInfo');
However the database doesn't get replaced by the new one.
How can I update my SQLite database when my iOS app starts?
Whenever you update database whether update your table column or create new table and save your changes, new "AquaInfo.sqlite" file generated.
So we have to replace it because we are updating database from external source.
Solution:
If you want database changes at application starting point. You have to write code manually like create table, add column in manual created table and change data type of certain column.
So you can achieve this via manually write code for creating table and related stuff.
Related
I have an existing indexedDB Database with the name of "APPV1" with version number "0.1".
indexedDB.open("APPV1", "1.0");
I want to use the dexie.js wrapper for indexedDB.
My question was how can I open the existing DB with dexie?
How can I add tables with existing DB with dexie?
How can I access data's with the help of dexie?
Note: I read their documentation and I'm not sure about how can they access the existing indexedDB using dexie.js
This topic should be covered here: https://dexie.org/docs/Tutorial/Migrating-existing-DB-to-Dexie
Edit: I just now updated dump-databases.html to allow converting a non-dexie database into Dexie code. (This was not needed before but since chromium removed the webkitGetDatabaseNames() API). So if your DB is created outside Dexie, press the Add Database button and enter the name of the DB to be able to dump it.
Is there a way to parse an .md file with php or javascript for code snippets.
My scenario is the following:
I have been migrating an old system (php4) to a Laravel Framework(php7) which needed Schema updates. All of this updates I made it manually( I know I could used migrations but the table structure is quite extensive and I want to persevere the old datas in my new system) and I made a history of changes over mysql updates in a Changelog.md.
Now I try to make an automised migration on schema check if matches some negative rules on table columns with a middleware. For example if Table X does not contain columns Y,Z .. than my system is obsoleted and needs an update of schema and I redirect to dedicated Controller.
no I want to read the changelog with changes let it run this mysql updates.
You can do it using http://parsedown.org/
$Parsedown = new Parsedown();
echo $Parsedown->text('Hello _Parsedown_!'); # prints: <p>Hello<em>Parsedown</em>!</p>
You can install it for Laravel easily : https://github.com/parsedown/laravel
I am trying to integrate socket.io + node.js + mysql . node-mysql is used to allow node.js to access the MySQL database. A table named tableA in the MySQL database updates with new data every 10 minutes.
Problem: Using node, I need the node server to continuously check tableA for changes whenever tableA gets updated(new row). What is a good way to achieve this?
I am thinking if I used setInterval(checkDb(tableA), 10*60*1000) for fetching all rows and check the changes, the checkDbquery function may not coincide with the database update.
I also happen to be using socket.io so will a good method be for the node system to emit('dbUpdated') from the node server to node client for realtime display of value.
Can anyone help me to do this?
Instead of firing query to fetch all records and then check if anything has changed, you can create a trigger on your tableA. Whenever any operation occurs like insert in your case, just save a timestamp in some other field or other table. So whenever you query after certain intervals you should query this single filed and save this time stamp. And use it to compare it with next timestamp found in query to see if anything has changed.
I want to make some forms which will be saved into a PhoneGap database (that one is declared in index.html). Note that the code I will be linking is not index.html, it is another one.
I tried to make the values for these forms to be variables, and then use PhoneGaps javascript to populate the database with these variables.
LINK TO MY CODE
I also want to know this:
* If I build this app, will I be able to store this data and be able to restart my phone and it would still be there? Or will the data be lost if I do so?
* Do I have to define a database on every HTML site or could I somehow make this data on this current HTML-file to be "INSERT" into the database declared in index.html?
Lets try and walk through your questions:
How permanent is data on your phone:
How permanent is local storage on Android and iOS?
Edit.html vs index.html
Did you try and just call the database with this piece of code:
db = window.openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
Ofc fill out with your own names that you created your original database with.- Opendatabase either creates the database or opens it.
I use phonegap to build applications for Android & IOS.
I store my database using sqlite.
I have a main javascript file in which the initialization of the DB & the main functions are written, then at the other pages I put the database functions related to that page.
The problem is that when I make some operations on the DB from another page then move to the next page & retrieve the data, I find that all what I made before was erased and it just brings the data from the main javascript file.
I'm wondering how can I let the data be saved & prevent it from being deleted whenever I move from one page to another.
The main javascript file that I use at all the pages contains this for the db initialization:
function populateDB(tx) {
tx.executeSql('DROP TABLE IF EXISTS Table');
}
Is this the problem ? Should I stop the table from being dropped every time I use the db.
But If I removed it, what should I make at the very first time while creating the DB ?
Yes you every time drop the table so when you move on next page you lost the data from previous page. you should make very first time creating db table like below.
function populateDB(tx) {
tx.executeSql('create table if not exists TableName (id integer)');
}