SQLAlchemy engine absolute path URL in windows

前端 未结 1 886
你的背包
你的背包 2020-12-28 09:04

I\'m trying to connect to a sqlite-database file in a python 3.3 application on a windows 7 x64 machine. To do so, the documentation states:

# sqlite://

        
相关标签:
1条回答
  • 2020-12-28 09:36

    On Windows it's a bit tricky, because you have to escape the backslashes:

    sqlite:///C:\\path\\to\\database.db
    

    Also, as Windows doesn't have the concept of root and instead uses drives, you have to specify absolute path with 3 slashes:

    sqlite:///C:\\Users\\Username\\AppData\\Roaming\\Appname\\mydatabase.db
    
    0 讨论(0)
提交回复
热议问题