Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- """Script para crear una base de datos de un restaurante"""
- import sqlite3
- conn = sqlite3.connect("restaurante.sqlite")
- cursor = conn.cursor()
- # tabla categoria
- query = 'CREATE TABLE categoria(\
- id INTEGER PRIMARY KEY AUTOINCREMENT,\
- nombre TEXT UNIQUE NOT NULL\
- )'
- cursor.execute(query)
- # tabla platos
- query = 'CREATE TABLE platos(\
- id INTEGER PRIMARY KEY AUTOINCREMENT,\
- nombre TEXT UNIQUE NOT NULL,\
- id_categoria INTEGER NOT NULL,\
- FOREIGN KEY(id_categoria) REFERENCES categoria(id)\
- )'
- cursor.execute(query)
- conn.commit()
- conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement