Python SQLite TypeError
<pre><code>from sqlite3 import *

def insert_record(Who, Invented):

    connection = connect(database = "activity.db")

    internet = connection.cursor()

    list = "INSERT INTO Information VALUES((Alexander_Graham, Phone))"

    internet.execute(list)

    rows_inserted = internet.rowcount

    connection.commit()

    internet.close()
    connection.close()

#GUI interface
from Tkinter import *
window = Tk()

the_button3 = Button(window, text='Record', command = insert_record).grid(row=1, sticky=W, padx=100,pady=5)
window.mainloop()
</code></pre>

<p>Alright, so what I'm trying to do is when I press the Record button, the values for Information (it have 2 fields called Who and Invented, respectively) in activity.db will add a record Alexander_Graham and Phone.</p>

<p>*activity.db is already premade in the same folder as the code</p>

<p>But instead I get this error:
TypeError: insert_record() takes exactly 2 arguments (0 given)</p>

<p>How do I fix it? </p>

<p>When you press button then tkinter runs function <code>insert_record()</code> always without any arguments. </p>

<p>You have to define function without arguments too.</p>

<pre><code>def insert_record(): 
</code></pre>

<p>Or with with default values ie.</p>

<pre><code>def insert_record(Who=None, Invented=None):
</code></pre>

<p>Or you have to assign function with arguments - you can do it using <code>lambda</code></p>

<pre><code>command=lambda:inser_record("Thomas Edison", "Bulb")
</code></pre>

python sqlite