Data not saving SQLite3 python3.4
<p>I am currently trying to create a sqlite database of peoples names and ip
While my code seems to work when I run it the data doesn't show up when I run <code>SELECT * from ips;</code> in terminal after running <code>SQLite3 ips</code>
Below is my code. Both it and the <code>SELECT * from ips;</code> are running in ~/Desktop/SQL</p>

<pre><code>import sqlite3 as sql
import socket
import struct
def iptoint(ip):
    return str(struct.unpack("i",socket.inet_aton(ip))[0])


database = sql.connect("ips")
createTable = True
if createTable:
    database.execute('''CREATE TABLE main.ips
    (FIRST_NAME TEXT PRIMARY KEY NOT NULL,
    SECOND_NAME TEXT NOT NULL,
    IP INT32 NOT NULL);''')

sampleIps = [("Edward","E","60.222.168.44")]
for first,second,ip in sampleIps:
    string = "INSERT INTO ips VALUES ('%s','%s','%s');"%(first,second,iptoint(ip))
    print(string)
    #Printing the string gives me INSERT INTO ips VALUES ('Edward','E','749264444');
    database.execute("INSERT INTO ips VALUES ('%s','%s','%s');"%(first,second,iptoint(ip)))

database.close()
</code></pre>

<p>My computer is running OSX 10.11.4, python 3.4 and SQLite 3.14.1</p>

<p>I have tried changing ips to main.ips and back</p>

<p>It doesn't look like you are committing to the database.  You need to commit before closing the connection in order to actually save your changes to the database.</p>

<p><code>database.commit()</code></p>

python sql sqlite sqlite3 python-3.4