conn = sqlite3.connect(':memory:')
conn.execute('CREATE TABLE words (word UNIQUE)')
with open('A.txt') as file_a:
    with conn:
        cursor = conn.cursor()
for line in file_a:
    cursor.execute('INSERT OR IGNORE INTO words VALUES (?)', (line.strip(),))
check whether a string is in a 2-GB list of strings in python