import sqlite3

if __name__ == '__main__':
    db = sqlite3.connect('sms.db')
    cur = db.cursor()
    cur.execute('''CREATE TABLE IF NOT EXISTS `sms_hashes` (
        `url` TEXT NOT NULL,
        `hash` BLOB NULL,
        `old_text` BLOB NULL
    )''')
    db.commit()
    db.close()

import sqlite3


def main():
    db = sqlite3.connect('sms.db')
    cur = db.cursor()
    cur.execute('''CREATE TABLE IF NOT EXISTS `sms_hashes` (
        `url` TEXT NOT NULL,
        `hash` BLOB NULL,
        `old_text` BLOB NULL
    )''')
    db.commit()
    db.close()


if __name__ == '__main__':
    main()
else:
    raise NotImplementedError

Move code into a separate function