Advertisement
teslariu

resto

Aug 5th, 2021
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import sqlite3
  5.  
  6. conn = sqlite3.connect("restaurante.db")
  7.  
  8. query = "CREATE TABLE categoria(\
  9.        id INTEGER PRIMARY KEY AUTOINCREMENT,\
  10.        nombre TEXT UNIQUE NOT NULL\
  11.        )"
  12.  
  13. cursor = conn.cursor()
  14.  
  15. cursor.execute(query)
  16.  
  17. conn.commit()
  18.  
  19. query = "CREATE TABLE platos(\
  20.        id INTEGER PRIMARY KEY AUTOINCREMENT,\
  21.        nombre TEXT UNIQUE NOT NULL,\
  22.        id_categoria INTEGER NOT NULL,\
  23.        FOREIGN KEY(id_categoria) REFERENCES categoria(id)\
  24.        )"
  25.  
  26. cursor = conn.cursor()
  27.  
  28. cursor.execute(query)
  29.  
  30. conn.commit()
  31.  
  32. conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement