Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. import sqlite3
  2. from sqlite3 import Error
  3.  
  4. def crea_conexion(ruta):
  5.     conexion = None
  6.  
  7.     try:
  8.         conexion = sqlite3.connect(ruta)
  9.         print("Se ha conectado correctamente a la base de datos SQLite")
  10.  
  11.     except Error as e:
  12.         print("Ocurrió el error '{e}'")
  13.  
  14.     return conexion
  15.  
  16.  
  17. conexion = crea_conexion("BaseDatos.sqlite")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement