Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Creates OR opens a file called mydb WITH a SQLite3 DB
- db = sqlite3.CONNECT('data/mydb')
- # GET a cursor object cursor = db.cursor()
- # CHECK IF TABLE users does NOT exist AND CREATE it
- cursor.EXECUTE('''CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, name TEXT, phone TEXT, email TEXT unique, password TEXT)''')
- # Commit the CHANGE
- db.commit()
- # Catch the exception
- EXCEPT Exception AS e:
- # Roll back any CHANGE IF something goes wrong
- db.ROLLBACK()
- raise e
- finally:
- # Close the db connection
- db.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement