How to use Sqlite Database in browser for offline usage - sqlite

I have developed one application in ionic for offline mode. I have used sqlite database to store the data. Now i want to create a browser build. But sqlite is not supported in browser. Is there any way to use sqlite in browser?
Or else is there any database which works same as sqlite for browser.(kindly do not suggest websql database and pouchdb)
i am using pouchdb for now, but there is lots of redevelopment because queries in pouchdb and sqlite are very different

As of this moment there is no way of using SQLite with ionic in the browser. Did you maybe find a solution to your own problem?
For anyone reading this that wants to purely use SQLite in their app (instead of localstorage) you can use a livereload build on a test device and easily debug and test your code this way. Just connect dev tools and see all the console messages.

Related

Importing a database using sqlite, flutter app

My main goal is to import a database into a flutter app using sqlite(sqlflite plugin), instead of having to hard code all of the create tables into the apps code.
*I want the information to be accessed to the phone locally(access data from phone on airplane mode) that is why i am using sqlite
I am having trouble finding information on this online and was seeing if anyone had experience in doing this or has documentation/examples that could help.
i think you are looking for this :
Open an asset database in this case you must have the database already and you don't need to create tables
Flutter supports an open source module SQFlite. SQFlite is a way of storing app data in Flutter Application. SQFlite is a Database plugin for flutter. It is highly reliable and embedded Database engine. All the CRUD operation in the database will run on a background thread. You can see a simple example of this here.

how to manage/edit sqlite in hybrid apps

Actually i'm new to hybrid app and i'm trying to make simple app using ionic with sqlite and i use google chrome console to log the app.
The question how can i manage/edit sqlite database?
Thank you.
A lot of the functionality you would see in a native app can be invoked using cordova tools.
http://ngcordova.com/docs/plugins/sqlite/
Try this plugin for a sqlite DB.
For temporary storage, you can use the localStorage of the browser.
Edit: I'm afraid I misread the question. To manage the DB as you would in phpmyadmin, you can use command line or a GUI.
https://www.sqlite.org/cli.html
I have used this GUI before
http://sqliteadmin.orbmu2k.de/

How can I use sqlite in appfog?

I'm using flask on appfog.com to make a personal blog. Today I tried to use sqlite. I can run the application locally with sqlite but when I update the app to AppFog, it does not seem to work. I can't find how to use sqlite in AppFog's docs. Can anyone tell me?
Thanks...
Sorry for my poor english:-)
It's not recommended to use sqlite for your production apps on AppFog because the file storage is ephemeral. Every time you update your app the database will get blown away. You're better off creating and binding a postgres, mysql, or mongodb database service for your app. You can continue to use sqlite db locally but your production app will use the bound service.
See the Bind Service section of: https://docs.appfog.com/languages/python/flask

Reading a local sqlite file from phonegap

I can create a sqlite DB in phonegap/html5 via window.openDatabase. I am going to have a large amount of data, so I want to ship it with the app.
So can I store a sqlite DB somewhere, within the app (It needs to work on both iOS and Android). I particular where is the shortName.db stored when I call
var db = openDatabase(shortName, version, displayName, maxSize);
And can I pre-populate this sqlite file. (In the phonegap environment)
Listed here are some solutions for iphone and android:
http://groups.google.com/group/phonegap/browse_thread/thread/5e57a728dc66a2a1?pli=1
I've not used PhoneGap, only created HTML5 apps that use Web SQL. However, if you're asking whether you can ship an app with a pre-populated SQLite database, then yes you can. Probably the simplest approach would be to provide the table creation scripts as part of the app. When it's first fired up, you can have the scripts run, and your database will then be fully initialised.
An alternative approach for deploying bulk data I came up is simply serialize it into text files and deploy the files together with the app.
You can use the File API provided by PhoneGap to load these files as strings, and parse them with Ext.util.JSON.decode().
Finally, use the MemoryProxy to integrate the decoded data with the rest of Sencha Touch and you are golden.

Anyone successfully used password on sqlite database in Monotouch?

I have a Monotouch app which uses a sqlite database. I want to encrypt the database so I am doing this:
_mainConnection = new SqliteConnection("Uri="+finalDB);
_mainConnection.Open();
_mainConnection.ChangePassword("mypassword");
However, its not working (on simulator and iphone). It gets this error:
at (wrapper managed-to-native)
Mono.Data.Sqlite.UnsafeNativeMethods.sqlite3_rekey
(intptr,byte[],int) <0x0005c> at
(wrapper managed-to-native)
Mono.Data.Sqlite.UnsafeNativeMethods.sqlite3_rekey
(intptr,byte[],int) <0x0005c> at
Mono.Data.Sqlite.SQLite3.ChangePassword
(byte[]) <0x00053> at
Mono.Data.Sqlite.SqliteConnection.ChangePassword
(byte[]) <0x0004b> at
Mono.Data.Sqlite.SqliteConnection.ChangePassword
(string) <0x0005b>
Has anyone successfully used password protection on an sqlite database in Monotouch?
As per my research there are a few options for database encryption using MonoTouch. I have a forthcoming blog post on the subject, but for now these are your top two options:
SQLCipher
I've automated the SQLCipher build process substantially. All it takes is a simple make command and you've got a library that you can link into your project. It makes use of the awesome SQLite-NET library. After that, all that's required is to provide the key in the SQLite.cs file.
SQLCipherNet: https://github.com/anujb/SQLCipherNet
CSharp-SQLite
This is a managed port of the SQLite library in C#. Performance is only about ~2x slower, which is pretty awesome considering it's not native code!
Encryption: http://code.google.com/p/csharp-sqlite/wiki/ENCRYPTION
Perf Benchmarks: http://code.google.com/p/csharp-sqlite/wiki/Benchmarks
Try adding ";Password=mypassword" to your connection string, and remove the call to ChangePassword.
Please note that, by default, the iPhone implementation of sqlite does not support encryption, so the sqlite commands for that will be no-ops.
You can get a (paid) copy of the encrypt-able version of sqlite from http://www.hwaci.com/sw/sqlite/see.html, and compile it into your application, making sure to remove the libsqlite3*.dylib from your project if you've linked that in.
You may have to do a bit of digging in the Monotouch documentation and/or experimentation to make sure that the Monotouch library itself is not including the default sqlite implementation, but in fact links to the implementation you specify. Try it first, if things still don't work that's where I'd start looking.
You can do this experiment without paying for the encrypted version, simply using the sqlite3 source code available on the net, with appropriate break points.
Good luck!
PS: Note that there is no comparable solution for Android at this point, this works on iPhone because iPhone runs native C code.
PPS: There is also SQLCipher that claims to encrypt sqlite on iPhone. However I found the configuration requirements to be below my standards for simplicity. I'm also not sure if it will properly insert itself between Monotouch's framework code and the default iPhone sqlite implementation.
SQLCipher for MonoTouch provides full database encryption for SQLite databases.
http://sqlcipher.net/sqlcipher-for-monotouch
There is also a SQLCipher on Mono for Android, which allows you to reuse the same code across Mono Touch and MonoDroid applications
http://sqlcipher.net/sqlcipher-for-monodroid
Just thinking out loud but could this be due to sqlite's dynlib that comes with the iPhoneSDK not being threadsafe?
For an alternative you might try looking at WWDC Vid 209 and just lock/encrypt the DB when you're outside the app.
You can probably do it yourself by issuing a "pragma rekey" in a raw SQLite query -- that is, if the SQLite version installed is actually SqlCipher.
I had the same problem but with a windows form application in C#.
I could not find the solution so i had to encrypt my data manually when saving it and decrypt it when retrieving.

Resources