Illegal invocation using SQLite in web - sqlite

import { SQLite } from 'expo-sqlite';
export const db = SQLite.openDatabase("db.db");
I tried to use sqlite in the expo and run from a browser, However, I get error TypeError: Illegal invocation, any can help me please

WebSQL API is so bad it was ultimately abandoned as a standard for the web.
The expo-sqlite module provides an SQL database with a WebSQL based interface. This is pretty powerful, and supports pretty much all the features of SQLite. SQLite is also perfect for exactly the kind of use case that apps with offline requirements have. It lets you store large amounts of structured data on disk and read only the parts you need for displaying the current screen into memory.
Maybe you should try #databases/expo
https://itnext.io/using-sqlite-in-expo-for-offline-react-native-apps-a408d30458c3
import connect, {sql} from '#databases/expo';
const db = connect('my-database');

Related

Is there a way to run GQL queries without defining entity model in python

I have a java, spring-data app that uses Datastore. I need a subset of this data to run analytics using python app. What I need in python app is essentially a join (yup, relational doesnt get out of me) between two "Kinds" queried by key of one kind.
NDB client requires creating same entity models in python to be able to query data, which is a drag. Why cant i simply run the console version of GQL(select * from kind) using python. Maybe I am missing something as this sort of querying is available in almost all relational and nosql DBs.
Your observations are correct: a GQL query cannot perform a SQL-like "join" query. This is documented on the GQL Reference for Python NDB/DB documentation page.
If you would like to submit a feature request to request its implementation, you can simply open an issue for it in the Public Issue Tracker.

How to backup Sqlite database if sqliteOpenHelper class is used

I'm quite new in c# and Xamarin android and I want to backup and restore my offline SQLite database created with sqliteOpenHelper Class, send and use that on another device. thanks in advance.
In Android API sets, the providers for SQLite library are available under, android.database.sqlite package. The most prominent types in the package are:
1. SQLiteOpenHelper: This is the main class that you need to inherit your classes from, in order to handle the database creation, opening or closing events. Even the events such as create new tables, or deleting the old tables and upgrading your databases to a latest version (such as upgrading the schema), are all handled here in this class-derived classes of yours.
2. SQLiteDatabase: This is the object that you get and use to either push the data to the database, or to read the data from the database.
3. SQLiteCursor: This is the cursor implementation for working with the data records that are returned after Query commands.
The way they all communicate is that, the main class for the data manipulation first of all inherits from SQLiteOpenHelperto get the functions to handle, then later has a field of type SQLiteDatabasein it to execute the functions for writing or reading the data.
For more information, you can check:
https://basicsofwebdevelopment.wordpress.com/2017/02/19/learning-sqlite-databases-in-xamarin-for-android/
https://www.c-sharpcorner.com/article/xamarin-android-develop-sqlite-database-using-sqliteopenhelper/

SQLite-PCL : Accessing my own created table?

I'm referring to SQLite-PCL tutorial here: https://code.tutsplus.com/tutorials/an-introduction-to-xamarinforms-and-sqlite--cms-23020
I'm very new to SQLite, so I'm lacking in knowledge in lots of basic things - I have tried Googling, can't understand most of it.
Is the call to new SQLiteConnection actually opens up the database or just saying that "the road to the database has been established, whether you access it or not is up to you"?
How do I check if there's already existing database in the devices? And if there is, how do I access it? I have Googled this, but it all seems to be a bit extreme - can't I just call simple OPEN the database?
Is it okay to have multiple SQLiteConnection instances to the same database, if I can be sure that I'm not going to do multiple transaction at the same time?
After I have INSERT into the database, close the app, open up the app back - how do I make sure that there is database created in previous session? Any way to debug this? Because I have no idea if the database is there or not, and I don't know how to access it either..
SQLiteConnection returns a connection object that is used to make subsequent queries
use File.Exists to see if the db file is already present
Yes
Again, use File exists to see if the db file is physically present
Xamarin's ToDo sample provides a good overview of using SQLite with Forms.

How to set SQLITE_CONFIG_SERIALIZED in ormlite

I am using Ormlite with SQLite in my android app. The app has multiple threads accessing the databse. How to enable SQLITE_CONFIG_SERIALIZED in ormlite?
You may be able to use the raw methods in the Daos to send commands to the underlying Sqlite database:
http://ormlite.com/docs/raw-update
Maybe something like:
fooDao.executeRaw("SQLITE_CONFIG_SERIALIZED;");
But it seems for this to work the Android Sqlite needs to be built a certain way:
http://sqlite.org/c3ref/c_config_getmalloc.html

How to Store User Preferences in an Adobe Flex/AIR Application

What's the standard way of storing user preferences in a Flex application for AIR? I need to store simple parameters like lists of recently opened files, window positions and sizes etc.
my favorite way to do it is to combine a VO with LSO (local shared object). If you have a LOT of settings, this doesn't work too well. The advantage is that you get a strongly typed settings object which is therfore bindable and has code introspection and completion.
The cool thing is it's only about 5 lines of code to manage an LSO. In addition, it's also pretty easy to manage a local encrypted store if you want to store any sensitive data.
registerClassAlias("SettingsVO",SettingsVO); //This lets us store a typed object in LSO
var settings:SettingsVO;
var settingsSO = SharedObject.getLocal("settings");
//Check to make sure settings exist... if not, create a new settings object
if( settingsSO.size && settingsSO.data && settingsSO.data.settings){
settings = settingsSO.data.settings as SettingsVO;
}else{
settings = new SettingsVO();
}
Now if you want to save settings you simply do
settings.someSetting = "newValue";
settingsSO.data.settings = settings;
settingsSO.flush();
And this solution works on BOTH AIR and Flex in any browser. Newer browsers will delete this data when clearing cookies, so beware of that.
I think the most flexible way is to use a local SQLite database. It gives you unlimited, structured storage and encryption if needed. See Peter Elst's introduction if you want to get more info.
There is no "Standard" way, but there are a lot of approaches, all which boil down to storing the user's preferences, then loading them up at runtime based on some uesr credentials, then changing the app based on those preferences.
You may store them in a server side database, such as SQL Server or MySQL; then have flex call a service which queries the database and returns the data.
You may store them as Shared Objects, which are the Flash version of browser cookies. (I believe they work on AIR applications too). This can get cumbersome with lots of data.
You may store them in an XML document and throw them on the server. Conceptually this is not much different than storing them in a server side database; but could get very tedious if you have a lot of users.
You could also store them, in an AIR app, locally using a SQLite database. SQLite is an embedded database used in Adobe AIR.
I don't bother with any of the fancy stuff. Just store it in an xml file in the application directory. Done.
Filestream does throw an error if you try to store it using File.applicationDirectory. I just trick the program...
var trickFile:File = File.applicationDirectory;
var file:File = new File(trickFile.nativePath + mySettings.xml);
Air falls for it every time.

Resources