Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created July 2, 2019 23:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save parzibyte/f120b21ddaeeb2dc1b73fec7e916ac7e to your computer and use it in GitHub Desktop.
import sqlite3
try:
bd = sqlite3.connect("libros.db")
cursor = bd.cursor()
sentencia = "SELECT * FROM libros;"
cursor.execute(sentencia)
libros = cursor.fetchall()
print("+{:-<20}+{:-<20}+{:-<10}+{:-<50}+".format("", "", "", ""))
print("|{:^20}|{:^20}|{:^10}|{:^50}|".format("Autor", "Género", "Precio", "Título"))
print("+{:-<20}+{:-<20}+{:-<10}+{:-<50}+".format("", "", "", ""))
for autor, genero, precio, titulo in libros:
print("|{:^20}|{:^20}|{:^10}|{:^50}|".format(autor, genero, precio, titulo))
print("+{:-<20}+{:-<20}+{:-<10}+{:-<50}+".format("", "", "", ""))
except sqlite3.OperationalError as error:
print("Error al abrir:", error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment