cursor.execute(
    """
    CREATE TABLE ip_address_associations (
        ip_address INTEGER PRIMARY KEY, 
        value TEXT
    )
"""
    )
cursor.execute('INSERT OR REPLACE INTO ip_address_associations VALUES (?, ?)',
    (int(ip_address('172.23.1.99')), 'pear'))
row = cursor.execute(
    'SELECT value FROM ip_address_associations WHERE ip_address = ?', (int(
    ip_address('172.23.1.99')),)).fetchone()
if row:
    value = row[0]
How to convert an IP address to something 32 bit you can use as a dict key