11

How can i use TypeORM with better-sqlite3?

on the official documentation, there is a section form better-sqlite3.

I already installed by typeorm@latest and typeorm@next but there is no options for better-sqlite3 yet.

If i try to force initialize it, i got the following error

MissingDriverError: Wrong driver: "better-sqlite3" given. Supported drivers are: "cordova", "expo", "mariadb", "mongodb", "mssql", "mysql", "oracle", "postgres", "sqlite", "sqljs", "react-native", "aurora-data-api", "aurora-data-api-pg".

Daniel Santos
  • 14,328
  • 21
  • 91
  • 174
  • If I'm not mistaken, you have to install https://github.com/JoshuaWise/better-sqlite3 --- with npm: `npm install better-sqlite3` – Protomen Jul 30 '20 at 14:19

1 Answers1

7

The better-sqlite3 driver was added in typeorm@0.2.26.

  1. Export your existing database.
  2. Update typeorm to 0.2.26 or higher.
  3. Install the package better-sqlite3. sqlite3 can be uninstalled.
  4. In your ormconfig.json change the type to "type": "better-sqlite3",
  5. Import the database exported in step 1.
None
  • 5,491
  • 1
  • 40
  • 51