简体   繁体   中英

What am I doing wrong and how do I fix it?

I am trying to insert data into a sqlite3 table. I have been experimenting with multiple solutions I have found online yet I can't seem to find a solution that works. My error is

    File "C:/Users/jaicedecelis/PycharmProjects/Terminal CRM/main.py", line 29, in <module>
    new_customer_entry()
  File "C:/Users/jaicedecelis/PycharmProjects/Terminal CRM/main.py", line 20, in new_customer_entry
    (firstname, lastname, stocknumber, emailaddress, phonenum1, phonenum2, phonenum3, leaseorbuy))
TypeError: 'str' object is not callable

This is my code

import sqlite3

conn = sqlite3.connect("customerList.db")
c = conn.cursor()


def new_customer_entry():
    firstname = input("First Name: ")
    lastname = input("Last Name: ")
    stocknumber = input("Stock Number: ")
    emailaddress = input("Email Address: ")
    phonenum1 = input("Cell Number: ")
    phonenum2 = input("House Number: ")
    phonenum3 = input("Work Number: ")
    leaseorbuy = input("Lease or Buy?: ")
    c.execute('CREATE TABLE IF NOT EXISTS customerProfiles(firstname, lastname, stocknumber, emailaddress, cellphone, housephone, workphone, leaseorbuy)')
    c.execute("INSERT INTO customerProfiles (firstname, lastname, stocknumber, emailaddress, cellphone, housephone, workphone, leaseorbuy) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
              (firstname, lastname, stocknumber, emailaddress, phonenum1, phonenum2, phonenum3, leaseorbuy))
    conn.commit()
    conn.close()
    print("Customer Profile Added for " + firstname + " " + lastname)

print("Welcome to Atlantic Terminal CRM")

selection = input("N : New, S : Search\n")
if selection == "N" or selection == "n":
    new_customer_entry()
# elif selection == "S" or selection == "s":
    # criteria = input("F : First Name, L: Last Name, S: Stock Number, P: Phone Number\n")
    # if criteria == "f" or criteria == "F":
       # fName = input("First Name: ")
    # if criteria == "l" or criteria == "L":
        # lName = input("Last Name: ")
    # if criteria == "s" or criteria == "S":
        # sNum = input("Stock Number: ")
    # if criteria == "p" or criteria == "P":
        # pNum = input("Phone Number: ")

You are missing a comma on the end of line 20.

c.execute("INSERT INTO customerProfiles (firstname, lastname, stocknumber, emailaddress, cellphone, housephone, workphone, leaseorbuy) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
              (firstname, lastname, stocknumber, emailaddress, phonenum1, phonenum2, phonenum3, leaseorbuy))

(Because you were continuing the rest of the c.execute() block on the next line.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM