Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 670 Bytes

File metadata and controls

25 lines (20 loc) · 670 Bytes

Python Decorator + Context Manager Example

This is a small educational project demonstrating:

  • How to use a context manager for resource management (database connection).
  • How to use a decorator to log query execution time.

Features

  • Clean and reusable code
  • Simulates connecting to and disconnecting from a database
  • Logs query execution time

Requirements

No external dependencies. Works with Python 3.x.

Usage

python main.py

## Example Output
Connecting to database...
Executing query: fetch_users
Fetching users from DB Connection Object
Query executed in 2.0005 seconds
['User1', 'User2', 'User3']
Closing database connection...