0

I've been teaching Intro to Python using Thonny at a library. Two years ago I added a class on SQL, also taught from the Thonny environment.

I wrote a bunch of scripts to demonstrate concepts, beginning each one with:

import sqlite3

connection = sqlite3.connect("C:\Python\sm_app.sqlite")
cursor = connection.cursor()

Followed by executing the cursor with the specific SQL script.

While this works on the computers Thonny was installed onto a few years ago, it does not work for new installations. The error message is: sqlite3.Operation Error: unable to open database

I searched but I've been unable to find sm_app.sqlite on the new installations.

Can someone explain the error and show me how to connect to sqlite in Thonny 4.0.2 and Python 3.10.9 64 bit on Win 11 machines?

Someone on another site said that my problem was with escape characters, and suggested using any of these: r"C:\Python\sm_app.sqlite" or "C:\Python\sm_app.sqlite"` or "C:/Python/sm_app.sqlite"

But, as I said, the older installations still work fine. I did try all 3 of the suggested strings, for completeness's sake, but no go. Same error.

1 Answers1

0

this is my first time answering in StackOverflow.

Go to the "Tools" tab, then go to "Manage packages..." and search "SQL" in the bar. It should appear the package from the next site: http://github.com/3kwa/sql and the PyPI site: https://pypi.org/project/sql/. You should click in Install button

I'm using Thonny in windows 11. 3.2.7

Hope it helps to you :D (I'm new using SQL library)