# 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()
Comments
0 B
|π
/π
0 B
|π
/π
0 B
|π
/π
0 B
|π
/π
0 B
|π
/π