Need a SQLite close method

Hi.

I have a mobile app where I can download a SQLite DB file from our servers, if it’s not already in the phone, and then open it.

I works fine, but I also want the ability to delete that DB, redownload it and reopen it.

It doesn’t work because there is no SQLite.close() method. I need that in order to be able to safely close the DB, delete the file, and then reopen the DB with same credentials.

1 Like

Do ExpoKit devs even read this forum?

Any “adding to backlog”, “won’t do it”, “on it” feedback?

It’s not much to ask, really.

Hi! We typically monitor https://expo.canny.io for feature requests.

@nikki can you take a look at this?

https://github.com/expo/expo/issues/639 <-- this may get at this issue too. Haven’t scoped it yet for any SDK work. Could scope it for an upcoming release!

My apologies for not knowing the proper place for feature requests.

Nikki, thanks. Is there a target sdk? I see 23 is already out.

I raised a feature request through canny for the “close”-method:
https://expo.canny.io/feature-requests/p/close-method-for-sqlite

The actual method sqlite3_close seems to be in the underlying code already.

A new close method was added to the SQLite API in this pull request: https://github.com/expo/expo-sdk/pull/112

This new method is already available in Expo 29, however, it isn’t ‘public’: Expo.SQLite.openDatabase() returns a WebSQLDatabase object that has Expo’s SQLiteDatabase in the _db property. As a result, to close the database you need to do something like this:

// Open the database
const db = Expo.SQLite.openDatabase("db_name");

// Close the database
db._db.close();

To fix this, a new public close method would need to be added to WebSQLDatabase in Expo’s fork of node-websql.

I added this explanation to @jankammerath’s feature request so that everyone is aware of the current status.

2 Likes