Advertisement
teslariu

base resto sqlite

Sep 8th, 2023
1,492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 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. cursor = conn.cursor()
  8.  
  9. query = 'CREATE TABLE categorias(\
  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 categorias(id)\
  21.         )'
  22.  
  23. cursor.execute(query)
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement