We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6df6a07 commit f930e37Copy full SHA for f930e37
1 file changed
crud-operations/crud_sql.py
@@ -6,12 +6,10 @@ def connect_to_db(db_path):
6
7
8
if __name__ == "__main__":
9
- connection = connect_to_db("birds.db")
10
- create_bird_table = """
11
- CREATE TABLE IF NOT EXISTS bird (
12
- id INTEGER PRIMARY KEY AUTOINCREMENT,
13
- name TEXT NOT NULL
14
- );
15
- """
16
- connection.execute(create_bird_table)
17
- connection.close()
+ with connect_to_db("birds.db") as connection:
+ connection.execute("""
+ CREATE TABLE IF NOT EXISTS bird (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ name TEXT NOT NULL
+ );
+ """)
0 commit comments