connect() import sqlite3 # Create a database in RAM db = sqlite3.connect(':memory:') # Create/open a file called mydb. db = sqlite3.connect('data/mydb') cursor and commit() # Get a cursor object cursor = db.cursor() #execute the query cursor.execute('''CREATE TABLE users(id INTEGER PRIMARY KEY, name TEXT, email TEXT)''') #commit it to the database db.commit() rollback() #rollback the execution db.rollback() fetchone() # obtains some rows from a table cursor.execute('''SELECT name,email FROM users''') #retrieve the first row user1 = cursor.fetchone() #Print the first column retrieved(user's name) print(user1[0]) fetchall() # obtains some rows from a table cursor.execute('''SELECT name, email FROM users''') #retrieve all the rows all_rows = cursor.fetchall() for row in all_rows: print('{0} : {1}'.format(row[0], row[1]))