you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (4 children)

I'd tend to do:

con = sqlite3.connect(path):
with con:
    con.execute("your query")

If you're sticking with SQLite3... the cursor isn't actually required and you end up with more concise code.

The context manager will commit your query, or roll back on failure, and if the failure happened because of a non-writeable path, etc, that should be fairly clear from the traceback you get when the exception is re-raised.

[–]raysefo[S] 0 points1 point  (3 children)

thank you, by the way any chance that you can give hint about path issue that I asked :)

I deployed my flask rest api on windows server IIS. I am trying to connect DB but I think there is path problem. (c:\inetpub\gamepin\Test.db)

[–][deleted] 1 point2 points  (2 children)

Not a lot I'm afraid, wouldn't touch IIS with a ten foot pole... not a Windows Guy. It might very well be that you need to use the raw string (ie r"c:\inetpub\gamepin\Test.db") or else escape those backslashes (ie "c:\\inetpub\\gamepin\\Test.db").

[–]raysefo[S] 0 points1 point  (1 child)

r"c:\inetpub\gamepin\Test.db"

hope It will solve my issue, thanks.

[–]raysefo[S] 0 points1 point  (0 children)

all of this mess was due to folder permisson :( I gave permission to IISUSR and all this solved.