Skip to content

Instantly share code, notes, and snippets.

@parzibyte

parzibyte/bd.py Secret

Created February 5, 2021 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/3831bad885b4a087b985f06e13df0ace to your computer and use it in GitHub Desktop.
Save parzibyte/3831bad885b4a087b985f06e13df0ace to your computer and use it in GitHub Desktop.
import sqlite3
NOMBRE_BASE_DE_DATOS = "diccionario.db"
def obtener_conexion():
return sqlite3.connect(NOMBRE_BASE_DE_DATOS)
def crear_tablas():
tablas = [
"""
CREATE TABLE IF NOT EXISTS diccionario(
id INTEGER PRIMARY KEY AUTOINCREMENT,
palabra TEXT NOT NULL,
significado TEXT NOT NULL
);
"""
]
conexion = obtener_conexion()
cursor = conexion.cursor()
for tabla in tablas:
cursor.execute(tabla)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment