Simple connection string not working on Windows 10 but works on Linux with Electron
See original GitHub issueWhat 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:
- Created 5 years ago
- Comments:7 (3 by maintainers)
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 besqlite:///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?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