To connect to a SQLite database on PyCharm you have two options:
- Manual connection and
- Automatic connection.
Manual connection
Use the following steps to perform the manual connection:
- Open the Database tab in PyCharm (usually on the right hand side)
- Right-click and select the New > Data Source option in the menu. A dialog box will pop up:
](/content/images/2022/07/pycharm-sqlite.jpg) - Select the SQLite driver (download it if necessary)
4 Add the Database URL likejdbc:sqlite:<absolute path to your db file>/db.sqlite
A concrete example would be:
jdbc:sqlite:C:/Users/myuser/PycharmProjects/app/db.sqlite
The automatic way
This way is simpler:
- Open the Database tab in PyCharm
- Locate the database file in the Project explorer (or in Windows Explorer)
- Drag and drop it in the Database tab
This should work easily. If it doesn't, it means you don't have the drivers installed and you need to go to the Manual method above and install the driver.
Member discussion: