Advertisement
teslariu

base_restaurante

Oct 16th, 2021
84
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import sqlite3
  5.  
  6. conn = sqlite3.connect("restaurante.db")
  7. cursor = conn.cursor()
  8.  
  9. query = 'CREATE TABLE categoria(\
  10.         id INTEGER PRIMARY KEY AUTOINCREMENT,\
  11.         nombre TEXT UNIQUE NOT NULL\
  12.         )'
  13.  
  14. cursor.execute(query)
  15.  
  16. query = 'CREATE TABLE platos(\
  17.         id INTEGER PRIMARY KEY AUTOINCREMENT,\
  18.         nombre TEXT UNIQUE NOT NULL,\
  19.         id_categoria INTEGER NOT NULL,\
  20.         FOREIGN KEY(id_categoria) REFERENCES categoria(id)\
  21.         )'
  22.  
  23. cursor.execute(query)
Advertisement
RAW Paste Data Copied
Advertisement