Skip to content

Migrate from sqlite3 to better-sqlite3 #170

@hadv

Description

@hadv

Summary

Migrate the backend database layer from sqlite3 to better-sqlite3 for improved performance and simpler API.

Motivation

Aspect sqlite3 better-sqlite3
API Async (callback/Promise) Synchronous
Performance Slower due to async overhead 2-10x faster for typical workloads
Simplicity More complex with callbacks Cleaner, simpler code
Transactions Complex to handle properly Easy: db.transaction(() => {...})()
Native builds Often problematic Generally more reliable
Maintenance Less actively maintained Actively maintained

Benefits for EthAura

  • Passkey credential storage is I/O-bound locally - SQLite operations are fast enough that synchronous calls won't block Node.js meaningfully
  • Simpler transaction handling - Passkey/guardian data operations need atomic transactions, which better-sqlite3 handles elegantly
  • Better prepared statements - More intuitive API for parameterized queries (important for security)
  • Fewer dependency issues - sqlite3 often has build problems with node-gyp

Tasks

  • Install better-sqlite3 and remove sqlite3
  • Update database initialization code
  • Migrate all database queries to synchronous API
  • Update transaction handling
  • Test all passkey CRUD operations
  • Test guardian/recovery operations
  • Update any error handling for sync exceptions

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions