I have been learning flask recently and encountered problems when using sqlalchemy. I am using win10 system and the configuration file is as follows:
class DevelopmentConfig(Config):
DEBUG = True
DATABASE_URI = 'sqlite:////F:/code/python/fishkeeping/fishkeeping/fish.db'
USERNAME = 'admin'
PASSWORD = 'a00123456'
SECRET_KEY = '11f0394a7e0c-4585-af6b-5b4efcf6fd8f'
After that, an exception occurred that the database could not be opened, and it was found that the path was modified by the program to
'C:\F:\code\python\fishkeeping\fishkeeping\fish.db'
After trying several times, I found that no matter what is followed by sqlite:////
, a C:\\
will be added in front, which is very strange. Please solve it.
淡淡烟草味2017-05-27 17:41:23
Official documents explain itengine = create_engine('sqlite:///C:pathtofoo.db') # Windows
engine = create_engine('sqlite:///C:pathtofoo.db') # Windows
engine = create_engine(r'sqlite:///C:pathtofoo.db') # Windows alternative using raw string
engine = create_engine(r'sqlite:///C:pathtofoo.db') # Windows alternative using raw string