Created
November 11, 2023 14:06
-
-
Save alexaleluia12/450cb70a2ee5104991d35dcf9598e186 to your computer and use it in GitHub Desktop.
exemplo sqlite com with em python, fecha recursos de forma automática
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextlib import closing | |
import sqlite3 | |
# db from - https://github.com/google-developer-training/basic-android-kotlin-compose-training-bus-schedule-app/blob/main/app/src/main/assets/database/bus_schedule.db | |
# source - https://www.digitalocean.com/community/tutorials/how-to-use-the-sqlite3-module-in-python-3 | |
with closing(sqlite3.connect("bus_schedule.db")) as connection: | |
with closing(connection.cursor()) as cursor: | |
rows = cursor.execute("SELECT * FROM Schedule").fetchall() | |
print(rows) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment