question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Simple connection string not working on Windows 10 but works on Linux with Electron

See original GitHub issue

What are you doing?

Trying to connect to SQLite in an Electron app using a connection string.

I am building the database path using electron getPath('home') for location and adding the file name to create the dbPath const shown below.

This fails Windows 10 (latest) but works on Linux (fedora 28)

const sequelize = new Sequelize(`sqlite:${dbPath}`);

This works on Linux and Windows 10

const sequelize = new Sequelize(null, null, null, {
  dialect: 'sqlite',
  storage: dbPath,
});

What do you expect to happen?

Connect to the database

What is actually happening?

SequelizeConnectionError: SQLITE_CANTOPEN: unable to open database file

Dialect: sqlite __Dialect version:__4.0.1 Database version: 4.0.1 Sequelize version: 4.38.0 Tested with latest release: 4.38.0

I don’t have any priority on this since I can use the more verbose connection style. It could be the combination of Electron, SQLite, and Sequelize or something I am doing wrong, I just wanted to post this in case anyone had a similar problem.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
faizanalhassancommented, Jul 29, 2021

Hi, are there any updates on this issue? I am using version 6, and when tried to apply an absolute path it creates a strange folder structure in the same directory. like if my path is D:\\repos\\node\\proj_name\\db.sqlite3 and for same problem, in sqlalchemy (an ORM written in python) we can use /// as prefix of absolute to avoid this issue, so the connection string will be sqlite:///D:\\repos\\node\\footlocker\\abc.db (Ref: https://stackoverflow.com/questions/19260067/sqlalchemy-engine-absolute-path-url-in-windows). This technique is not helpful in case of Sequelize. Is there any solution?

0reactions
lucasjvwcommented, Aug 2, 2022

This is still an issue as of today, sequelize 6. I can specify a path on the current Windows drive: sqlite:/temp/database.db

But trying to specify a different drive either fails or creates a ‘d’ folder in the current working directory: sqlite:D:/temp/database.db sqlite:/D:/temp/database.db sqlite:///D:/temp/database.db

It would be great if this could be resolved

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to install electron on windows 10 - Stack Overflow
I am trying to install electron on windows 10 but not working. My environment is Windows 10, x64, 16gb ram. I have install...
Read more >
Connecting to Sqlite Database in Electron JS - YouTube
It's lightweight, it's portable and can process normal SQL commands. In this video I show you how to connect and work with a...
Read more >
.net core api not loading connectionString from appsettings in ...
This sounds like the appsettings.json Connection strings are not being read by the application (I may be wrong). On IIS this works as...
Read more >
ElectronCGI - Cross Platform .Net Core GUIs with Electron
Do you have same simple example? I tried changing the target framework in .csproj but that did not work. Rui Figueiredo • 3...
Read more >
Quick Start | Electron
Whereas Linux and Windows apps quit when they have no windows open, ... the Node.js process.versions object and runs a basic replaceText helper...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found