Home > Net >  sqlalchemy not connecting to database file on networked file server. sqlite3 is connecting though
sqlalchemy not connecting to database file on networked file server. sqlite3 is connecting though

Time:07-23

Basically trying to connect a flask app to a sqlite database file on a networked windows file server using flask-sqlalchemy (fully aware of the considerations when using a sqlite database over a network.) The flask app was not connecting to the database and I was using sqlalchemy to troubleshoot.

I can connect with the following line: sq2_db = sqlite3.connect(r"//ppcou.ucsc.edu\Data\Archive_Data\archives_app.db")

...but the following elicit an error:

db = sqlalchemy.create_engine(r"sqlite:////ppcou.ucsc.edu\Data\Archive_Data\archives_app.db")
db.connect()
db = sqlalchemy.create_engine(r"sqlite:///ppcou.ucsc.edu\Data\Archive_Data\archives_app.db")
db.connect()

Error:

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unable to open database file
(Background on this error at: https://sqlalche.me/e/14/e3q8)

FYI This solves to True:

os.path.exists(r'\\ppcou.ucsc.edu\Data\Archive_Data\archives_app.db')

Any thoughts?

CodePudding user response:

Gord Thompson's comment was correct. Adding an addition slash was the remedy.

db = sqlalchemy.create_engine(r"sqlite://///ppcou.ucsc.edu\Data\Archive_Data\archives_app.db")
db.connect()
  • Related