码迷,mamicode.com
首页 > 数据库 > 详细

[SQLite]SQLite URI配置

时间:2018-09-03 13:39:02      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:ase   $path   sql   sla   mit   ota   init   engine   com   

脱离新手文档使用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配置

标签:ase   $path   sql   sla   mit   ota   init   engine   com   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!