- This topic has 19 replies, 3 voices, and was last updated 10 years, 2 months ago by Darshan Patel.
-
AuthorPosts
-
Darshan PatelParticipanthi wayne,
I am developing an app for iphone, and everything is going well, all thanks to the support forum and examples provided by you.
I have created a database (that is very huge in size… around 18k records) and its working very fine… all the search queries and everything works good.
But my question is that how can i use this database when i deploy the app on a mobile device??
because the mobione emulator uses WEB SQL which is accessible only when the app is running and after i call the openDatabase() and there no such option as export or import.does mobione generate any db file on the local filesystem which i can access and include it in the build process??
really searching for solution to this thing… hope you have one.
thanks,
Darshan
support-michaelKeymasterMobiOne apps are built on the cordova/phonegap sdk. Thus if you are using the webdb you can not open a db file directly but instead must load webdb from another data source. Here are some ideas to consider:
1) package the db records in a file that is included in the app. Then on 1st start read the data file and update webdb with the data. For example package the db as a json file.
2) another idea that we used recently in a genuitec app is to pull app data from a web services.
3) similar to #1 is to use a different db such as one of the nosql type db systems. You build the db and package it and the nosql engine with app. Personally I have not used this approach and it could be an exchange of 1 set of issue for another. Can’t really say…
Darshan PatelParticipanti had thought of few options… and they where some what similiar to option 1 and 2 of yours.
but the problem is that the db size is quite huge. 18k records… so i think pulling this much data from a web services will not be a good option and also if i package the db records in a file which i was thinking of doing it in a .sql file then size is a problem(coz that file size gets around 6mb alone) and also i am doubtful that will app be able to fire 18k records on first start..
so can you suggest some other solutions??
thanks.
support-michaelKeymasterDid you rule out option #3 to use a web db system that will support packaging a db file directly in the app?
An example that I recall a mobione user promoting a while back is http://pouchdb.com/
I can not personally speak for such solutions.I was wondering what the db initialization time might look like. For example I created a simple table w/ 2 columns and inserts 20K rows. The function runs in 1 sec on my iphone5s (16G). Before ruling out a 1 time population phase for the app you might try evaluating the time to read a data file and load it into the db.
Lastly, perhaps others have some experience that they would like to share?
Darshan PatelParticipantokay… i’ll try using pouchdb and will also try out option #1 to see how it goes…
do you have some examples which uses the other web db systems? like using WEBSQL was so easy… i wish it had option like exporting the db…
meanwhile, if anyone in the past had a similiar query… please share your experience..
thanks michael.
Darshan PatelParticipantpouchDB is not something that i need…
can you help me with the location?, as where the database file is created when using WEBSQL
support-michaelKeymaster>can you help me with the location?, as where the database file is created when using WEBSQL
The websql db file location is not generally accessible. If you are testing on the simulator you can find it with the custom chrome profile that the simulator creates at <userhome>\appdata\local\temp\mobione_mobilewebsimulator_userdata\
If you are looking for the db on a device you would need access to the filesystem.
What’s your plan?
Darshan PatelParticipantBingo!! got the file…
thanks..i am just trying if this can work… i am thinking of packaging this file in .ipa file… so on first use i’ll do something like moving this file to the location on device where the dbfiles are created… dont know if its possible.. just gonna give it a shot…
what do you think??
support-michaelKeymaster>what do you think??
good luck my friend! I hope it works.
Darshan PatelParticipanta little help please…
where is the webSql db file created on iphone device?? how can i access it through javascript code… or whether is it possible to do it in the first place??
thanks,
Darshan
support-michaelKeymaster>where is the webSql db file created on iphone device?? how can i access it through javascript code… or whether is it possible to do it in the first place??
The html5 webdb api does not provide access to the physical db file or specify a specific db implementation. Sqlite has been the defacto implementation for android and ios because they both use the webkit implementation. I do not know where the file is stored. I would have recommended this approach in my 1st reply if I considered it viable; I don’t.
Darshan PatelParticipantyes.. ofcourse you would had said it before only if it was possible…
but i searched a lot on internet and found out that people have implemented this method but yes using Objective-C….
and they are placing the db in “~Library/Safari/databases/”.and i know there is no way we can do it using web api.. but i am just trying if we can create one.. through any mean…
any guidance will be appreciated…
meanwhile i’ll keep searching on this… and also try the other option of running the insert script on first install to see who it goes…
thanks,
Darshan
Darshan PatelParticipantscrap everything… i am using option #1. It is working fine, takes hardly 5secs to populate the WEBDB. 🙂
but the problem now is with packaging the db records files… its size is 5mb, so i am gonna compress it before packaging it.
so can you provide some easy example or tutorial for “reading data from a zipped file” or “how to unzip a file using javascript”..
thanks,
Darshan
support-michaelKeymasterHere’s my 2 cents on this continued topic of optimization. I learned a long time ago that you can NOT optimize intuitively. You end up working on the wrong problem and creating solutions who’s complexity cost much more than the optimization saves. I have muddled up a few projects by prematurely optimizing a design – in almost all cases I threw it all away and went with the most simple solution – big waste of time.
You started out “assuming” that directly loading the db would be too slow without actually knowing what the time cost would be. So rather than answer your technical questions I created a simple example that loads the webdb programmatically with 20K rows in under 1 sec. That was enough for me to stop working on any other solution than a direct load of the db.
Now you want to reduce the size of your db from 5MB to ?MB and at runtime expand it and then load it.
My question is what savings are you really expecting for the added complexity? I would sacrifice a couple of extra megs in increased app size in order to ship the app sooner and get it in users hands. (no arrogance intended in this next recommendation) Just say’n I don’t think its worth your time messing with this now. Ship your product. If it’s successful and a little bloated then maybe its worth revisiting compression. Most likely you will find other areas where your energy is better invested such as cool new user features. But then again I would favor quicker startup and loading at runtime (better UX) than app download of an extra 10-15 secs. Lastly, you might minimize the json which does not require any special runtime consideration.
Darshan PatelParticipantso true my friend!!! so true… i wasted my whole yesterday doing this, i was able to load my compressed data but its takes forever to load it… whereas on the other side my uncompressed db takes hardly 2secs to populate… i wished i had seen ur post b4 wasting my time…
-
AuthorPosts