Skip to content

screen #657

Description

@wahid1438-web

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions