def store_listings(db, listings):
    """
    Store listings in database.

    Listings already contained in the database are ignored.

    Returns the number of listings that were stored.
    """
    cursor = db.cursor()
    tuples = [(x, y['street'], y['number'], y['suburb'], y['rent'],
              y['area']) for x, y in listings.iteritems()]
    sql = '''INSERT OR IGNORE INTO listings (id, street, number, suburb, rent,
             area) VALUES (?, ?, ?, ?, ?, ?);'''
    cursor.executemany(sql, tuples)
    db.commit()
    return cursor.rowcount