Download our e-book of Introduction To Python
Neha Kumawat
3 years ago
import sqlite3
try:
con = sqlite3.connect('de.file.db')
cursor = con.cursor()
print("Database created and Successfully Connected to SQLite")
Query = "select sqlite_version();"
cursor.execute(Query)
record = cursor.fetchall()
print("SQLite Database Version is: ", record)
cursor.close()
except sqlite3.Error as error:
print("Error while connecting to sqlite", error)
finally:
if con:
con.close()
print("The SQLite connection is closed")
Database created and Successfully Connected to SQLite
SQLite Database Version is: [('3.22.0',)]
The SQLite connection is closed
import sqlite3
conn = None
try:
conn = sqlite3.connect("db_file.db")
print(sqlite3.version)
except Error as e:
print(e)
finally:
if conn:
conn.close()
2.6.0