npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

expo-sqlite-legacy-adapter

v0.2.0

Published

Adapter for the newer (SDK 51+) Expo-SQLite to behave in a WebSQL compatible way similar to the original legacy adapter

Downloads

313

Readme

Expo SQLite Legacy Adapter

This library provides a wrapper around the newer React Native Expo SDK 51+ expo-sqlite, enabling it to behave like the older expo-sqlite/legacy module that was removed starting from SDK 52.

Installation

npm install expo-sqlite-legacy-adapter

Usage

import { createWebSQLWrapper } from 'expo-sqlite-legacy-adapter';
import * as ExpoSQLite from 'expo-sqlite';

const WebSQLWrapper = createWebSQLWrapper(ExpoSQLite);
const openDatabase = WebSQLWrapper.openDatabase;

// In your project, you can now use openDatabase as if nothing ever happened!
export default openDatabase;


// e.g. just do this
const db = openDatabase('my-database.db');

// Use the database as you would with the legacy API
db.transaction(tx => {
    tx.executeSql('CREATE TABLE IF NOT EXISTS items (id INTEGER PRIMARY KEY NOT NULL, name TEXT);');
});

Why Make This?

The rationale behind creating this library stems from the need to support legacy libraries that rely on WebSQL, which is no longer natively available on Expo/React-Native starting from Expo SDK 52. For instance, my previous patches to projects like IndexedDBShim to enable IndexedDB functionality on React Native would not work without WebSQL support. This adapter bridges that gap, ensuring compatibility and extending the usability of such libraries.

Compatibility

  • Requires Expo SDK 51 or higher.

I have included a tests.ts file with the package. You may try importing it from expo-sqlite-legacy-adapter/tests, and it can be run on Expo SDK 51 (with expo-sqlite installed) as follows.

import { runComparisonTests } from 'expo-sqlite-legacy-adapter/tests';

// Somewhere else
runComparisonTests()

Due to limited time, I must admit I relied on LLMs to help create the tests, but as far as I'm concerned it looks to be valid.

Results are as follows, which shows rather compliant behaviour with the original library. I've used this in a few side projects too which should help test its validity somewhat too.

As for the error codes, I cannot guarantee full 100% same behaviour. YMMV. Open to PRs.

 LOG  🏁 Running WebSQL tests on a clean slate…
 LOG  🔍 Detailed Results:
 LOG  
• Test#1: INSERT returns insertId & rowsAffected=1
 LOG      Expected: [predicate]
 LOG      Legacy : ✔ PASS → {"insertId":1,"rowsAffected":1}
 LOG      Shim   : ✔ PASS → {"insertId":1,"rowsAffected":1}
 LOG  
• Test#2: UPDATE then SELECT yields updated value
 LOG      Expected: 2
 LOG      Legacy : ✔ PASS → 2
 LOG      Shim   : ✔ PASS → 2
 LOG  
• Test#3: syntax error → rollback, no final rows
 LOG      Expected: {"sawError":true,"finalCount":0}
 LOG      Legacy : ✔ PASS → {"sawError":true,"finalCount":0}
 LOG      Shim   : ✔ PASS → {"sawError":true,"finalCount":0}
 LOG  
• Test#4: write in readTransaction throws
 LOG      Expected: true
 LOG      Legacy : ✖ FAIL → false
 LOG      Shim   : ✖ FAIL → false
 LOG  
• Test#5: no-callback executeSql silently succeeds
 LOG      Expected: true
 LOG      Legacy : ✔ PASS → true
 LOG      Shim   : ✔ PASS → true
 LOG  
• Test#6: errorCallback returns false suppresses rollback
 LOG      Expected: 1
 LOG      Legacy : ✔ PASS → 1
 LOG      Shim   : ✔ PASS → 1
 LOG  
• Test#7: parameter binding & NULL
 LOG      Expected: [predicate]
 LOG      Legacy : ✔ PASS → {"insertId":1,"rowsAffected":1}
 LOG      Shim   : ✔ PASS → {"insertId":1,"rowsAffected":1}
 LOG  
• Test#8: PRAGMA user_version = 123 → read back 123
 LOG      Expected: 123
 LOG      Legacy : ✔ PASS → 123
 LOG      Shim   : ✔ PASS → 123
 LOG  
• Test#9: UPDATE no match → rowsAffected = 0
 LOG      Expected: 0
 LOG      Legacy : ✔ PASS → 0
 LOG      Shim   : ✔ PASS → 0
 LOG  
• Test#10: multi-statement in one executeSql
 LOG      Expected: undefined
 LOG      Legacy : ✔ PASS → {"mode":"tx-success-no-callback"}
 LOG      Shim   : ✔ PASS → {"mode":"tx-success-no-callback"}
 LOG  
✅ Summary:
 LOG      Legacy failures: 1/10
 LOG      Shim   failures: 1/10
 WARN  ⚠️ Shim has spec deviations—please review above.

License

WTFPL