python - flask encountered a sqlite path problem when using sqlalchemy under windows. It always automatically adds a c:// in front.
迷茫
迷茫 2017-05-27 17:39:23
0
2
737

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.

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
漂亮男人

means that your sqlite is followed by 3 slashes instead of 4.

淡淡烟草味

Official documents explain it
engine = create_engine('sqlite:///C:pathtofoo.db') # Windowsengine = 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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!