Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

connect to sql database python

import sqlite3

try:
    sqliteConnection = sqlite3.connect('test.db')
    cursor = sqliteConnection.cursor()
    print("SQLITE Connection Established!")
    cursor.close()

except sqlite3.Error as error:
    print("Error while connecting to sqlite", error)
finally:
    if (sqliteConnection):
        sqliteConnection.close()
        print("Connection closed")
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #connect #sql #database #python
ADD COMMENT
Topic
Name
2+9 =