gladiator
0
Q:

python sqlite

import sqlite3

try:
    sqliteConnection = sqlite3.connect('SQLite_Python.db')
    cursor = sqliteConnection.cursor()
    print("Database created and Successfully Connected to SQLite")

    sqlite_select_Query = "select sqlite_version();"
    cursor.execute(sqlite_select_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 (sqliteConnection):
        sqliteConnection.close()
        print("The SQLite connection is closed")
2
# You can run SQLite3 on python without downloading anything.
# The client is pre-installed in Python.
import sqlite3

connection = sqlite3.connect("Database_name.db")
cursor = connection.cursor()

# Now you can run SQLite3 commands by doing this:
cursor.excecute("WHATEVER COMMAND YOU WANT TO RUN")
0

New to Communities?

Join the community