Sqlite3 INSERT query ERROR?
<p>i want to insert in my DB 2 strings var </p>

<p>one entered from the user ==> H and </p>

<p>one generated form the chatbot==> B</p>

<p>Here is the code:</p>

<pre><code># initialize the connection to the database
sqlite_file = '/Users/emansaad/Desktop/chatbot1/brain.sqlite'
connection = sqlite3.connect(sqlite_file)
connection.create_function("REGEXP", 2, regexp)
cursor = connection.cursor()
connection.text_factory = str
connection = open

def new_data(Input,Output):
     row = cursor.execute('SELECT * FROM chatting_log WHERE user=?',(Input,)).fetchone()
     if row:
        return
     else:
        cursor.execute('INSERT INTO chatting_log VALUES (?, ?)', (Input, Output))

while True:
   print(("B:%s" % B))  
   H = input('H:')
   New_H= ' '.join(PreProcess_text(H))
   reply= cursor.execute('SELECT respoce FROM Conversation_Engine WHERE request REGEXP?',[New_H]).fetchone()
   if reply:
      B=reply[0]
      new_data(H,B)
</code></pre>

<p>The codes works perfectly in generating and selecting  the replay from the DB , but the problem is when i go back to the chatting_log table in the DB there is no data?</p>

<p>PS: i am using python 3</p>

<p>thank you,</p>

<p>Always remember to commit the changes that you make. In this case: <code>connection.commit()</code>. Except it looks like you overrode your <code>connection</code> variable.</p>

python mysql python-3.x