Skip to content

Instantly share code, notes, and snippets.

@BexTuychiev
Last active July 21, 2020 06:06
Show Gist options
  • Save BexTuychiev/f8a6cd7fd6b46d0657195757f3e7a265 to your computer and use it in GitHub Desktop.
Save BexTuychiev/f8a6cd7fd6b46d0657195757f3e7a265 to your computer and use it in GitHub Desktop.
from sqlalchemy import create_engine
# create an engine
engine = create_engine("sqlite:///sample.db")
try:
# Establish a connection
connection = engine.connect()
print('Connection successful!')
except Exception as error:
print("Something is wrong. Getting this error:\n", error)
finally:
connection.close()
print('Connection closed!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment