0

So I just begin to learn about databases, and I am trying to do some test on python shell, but I can not even create a database.

    import sqlite3                                                         
    path="C:/Users/cleme/Documents/programmes"
    conn=sqlite3.connect(path)

I tried to put an E instead of a C, but it didn't work. And I am on my computer, so I should be able to change every file.

  • 1
    I'm not on Windows, but shouldn't you use backslashes instead of slashes? In this case, use a raw string to avoid escaping problems: `path = r"C:\Users\cleme\Documents\programmes"` – Thierry Lathuille May 01 '18 at 17:19
  • Is programmes the name of a folder, or the name of the database you're trying to create? – sjw May 01 '18 at 17:25
  • 1
    If nothing else, we need a specific exception or error, not just the phrase "doesn't work". We can definitely make some guesses (bad escaping of the path is a likely cause; passing a directory and not a filename, likewise), but without a more complete description of the error, they're just guesses. – Charles Duffy May 01 '18 at 17:26
  • 1
    @ThierryLathuille: In general, regular slashes work fine under Windows and cause less quoting problems. – varro May 01 '18 at 17:27
  • If it *is* the use of backslashes that's at fault, that would make this a duplicate of [Python file not found error](https://stackoverflow.com/questions/19767179/python-file-not-found-error) – Charles Duffy May 01 '18 at 17:27
  • @CharlesDuffy Well, those are backslash issues, but the asker isn't using backslashes. Your first comment is the most important... we need a full traceback to get a better idea of what the problem is. – glibdud May 01 '18 at 17:32
  • 1
    Thank you very much. it is because I tried to create my database into folder rather than into a file. – clement boutaric May 01 '18 at 17:54

0 Answers0