January 2019
Beginner
318 pages
8h 23m
English
Now, we will see how to connect to the database. For that, we are going to create a script. Python already has a sqlite3 module included in the standard library. We just have to import it whenever we are going to work with SQLite. Create a connect_database.py script and write the following content in it:
import sqlite3con_obj = sqlite3.connect('test.db')print ("Database connected successfully !!")
Run the script and you will get the following output:
student@ubuntu:~/work $ python3 connect_database.pyOutput:Database connected successfully !!
In the preceding example, we imported the sqlite3 module to perform the functionality. Now, check your directory and you will find the test.db file created in your directory. ...
Read now
Unlock full access