25

Trying to format a database using SQLAlchemy but when I run create_all on the metadata, I get the above error. I created the engine using the following path for user Tyre77:

engine = create_engine('sqlite:////tyre77/OmniCloud/database.db')

I've walked through and there is a file 'database.db' at that path, but perhaps I typed it wrong?

4
  • From your question, i am unclear if you are using windows or a unix like os. If you are on linux, it looks like you have one too many / characters after the file: if you are on windows, have you tried using a file on the local disk? Commented Sep 5, 2011 at 2:09
  • @Carl sorry I am on running OS X Lion and that should be a local path Commented Sep 5, 2011 at 2:41
  • I think you've got one too many slashes. There should be three. Commented Sep 5, 2011 at 2:55
  • Okay. I thought in some of the documentation for SQLAlchemy it said there are 3 but then if you are providing a direct path there are 4 but may have made that up Commented Sep 5, 2011 at 3:00

3 Answers 3

47

You mention that it is a path to user tyre77 on OS X, so shouldn't that be sqlite:////Users/tyre77/OmniCloud/database.db?

Also, three slashes for relative paths, four for absolute paths.

Sign up to request clarification or add additional context in comments.

1 Comment

three slashes for relative paths, four for absolute paths. Highlight of the day
7

I had the same problem in windows 8.1. Based on sqlalchemy documentation:

sqlite:////db_absolute_path

sqlite:///db_relative_path

(notice that the second line above has only 3 slashes) In my case providing relative path helped.

Comments

1

After reading the docs on sqlite urls here, I decided you have the right number of slashes. Apparently, it uses the same parser to pull out the path as the remote connection engines, so the "server name" that would go between the second and third slash is left blank.

If you want to specify an absolute path, you are going about it the right way. Check to be sure you are providing an absolute path. Three slashes may be able to specify a relative path, but you need to know the current working directory of your app, which might break when you delay your app.

2 Comments

In the example, they show the path sqlite:///:memory:... so should there not be another slash to begin the root directory?
I believe memory is a special case, so I wouldn't use it as an example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.