首页 > 数据库技术 > 详细

[SQLite]SQLite URI配置

时间:2018-09-03 12:45:01      阅读:144      评论:0      收藏:0      [点我收藏+]

脱离新手文档使用SQLAlchemy配置sqlite,才发现sqlite的URI指定有点特别.

https://github.com/mitsuhiko/flask-sqlalchemy/issues/469

#Unix/Mac - 4 initial slashes in total
engine = create_engine(‘sqlite:////absolute/path/to/foo.db‘)
#Windows
engine = create_engine(‘sqlite:///C:\\path\\to\\foo.db‘)
#Windows alternative using raw string
engine = create_engine(r‘sqlite:///C:\path\to\foo.db‘)

 注意Windows下sqlite后是三道杠. 因为比较常见的是linux下的配置文档,所以很容易误解为正常的配置就是四道杠. 实际的URI格式应为sqlite:///{$path}.

斜杠有误的话会报错: Unable to open the sqlite database file

[SQLite]SQLite URI配置

原文:https://www.cnblogs.com/oDoraemon/p/9577760.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!