Answers for "how to how to give variable data to sqlite statement in python"

SQL
2

how to insert string variable into sqlite database

def create_db():
    with con:
        cur = con.cursor()
        cur.execute("DROP TABLE IF EXISTS Contacts")
        cur.execute("CREATE TABLE Contacts (First Name TEXT, Last Name TEXT, Phone TEXT, Email TEXT);")
        cur.execute("INSERT INTO Contacts VALUES (?, ?, ?, ?);", (firstname, lastname, phone, email))

        ## call commit on the connection...
        con.commit()
Posted by: Guest on February-25-2020

Code answers related to "how to how to give variable data to sqlite statement in python"

Code answers related to "SQL"

Browse Popular Code Answers by Language