Python GUI TKINTER SQLITE3 ошибка для следующего кода - PullRequest
0 голосов
/ 20 октября 2019

КОД: -

def datasave():
    conn = sqlite3.connect('lpugym.db')
    c = conn.cursor()
    c.executemany('INSERT INTO lpugym(name,phone) VALUES (?,?),(name.get(), phone.get();')
    c.execute('INSERT INTO lpugym ((phone) VALUES (phone.get())')
    if var.get()==1 :
        c.execute('INSERT INTO lpugym ((gender) VALUES (Male)')
    else:
        c.execute('INSERT INTO lpugym ((gender) VALUES (Female)')
    if var2.get()==1 :
            c.execute('INSERT INTO lpugym ((package) VALUES (Monthly)')
    if var2.get()==2 :
            c.execute('INSERT INTO lpugym ((package) VALUES (Yearly)')
    global price
    if var2.get()==1 :
            price=2500*var1.get()
            c.execute('INSERT INTO lpugym ((price) VALUES (price)')
    if var2.get()==2 :
            price=2450*var1.get()*12
            c.execute('INSERT INTO lpugym ((price) VALUES (price)')
    c.execute('INSERT INTO lpugym ((address) VALUES (address.get())')
    c.commit()
    c.close()
    conn.close()

Вывод

Исключение при обратном вызове Tkinter (последний вызов последнего): строка файла 1702,в вызов return self.func(*args) Файл "S: editable.py", строка 105, в сохранении данных c.executemany('INSERT INTO lpugym(name,phone,gender,package,price,address) VALUES (?,?),(name.get(), phone.get();') Ошибка типа: функция принимает ровно 2 аргумента (задано 1)

1 Ответ

1 голос
/ 21 октября 2019

Добавьте еще одну скобку в конец phone.get() в операторе .executemany.

c.executemany('INSERT INTO lpugym(name,phone) VALUES (?,?),(name.get(), phone.get());')

...