github / github/codespaces-jupyter

screen

Open
#657 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
894
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

import mysql.connector
from contextlib import contextmanager

DB_CONFIG = {
"host": "localhost",
"user": "root",
"password": "",
"database": "School_Fees_DB"
}

@contextmanager
def get_db():
conn = mysql.connector.connect(**DB_CONFIG)
cursor = conn.cursor(dictionary=True)
try:
yield cursor
conn.commit()
except Exception as e:
conn.rollback()
raise e
finally:
cursor.close()
conn.close()

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.