UD - FLASK - vanilla SQL

https://arac.tecladocode.com/

1. Create Table

INTEGER PRIMARY KEY for automatically increment id.

To create a table, you need to run $ python create_table.py, before running app.

# create_table.py
import sqlite3

connection = sqlite3.connect('data.db')
cursor = connection.cursor()

create_table = "CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, username text, password text)"
cursor.execute(create_table)

create_table = "CREATE TABLE IF NOT EXISTS items (name text PRIMARY KEY, price real)"
cursor.execute(create_table)

connection.commit()
connection.close()

2. Sign Up

UserRegister class POST method to handle signup

create endpoint

For GET method, we don't need connection.commit().

3. Find user

4. Item

Last updated

Was this helpful?