Skip to content

Database Connection Module #4

@cordialApple

Description

@cordialApple

Your task is to create a Database Connection Module. This means you need to create Python code that will handle all connections to the TimescaleDB instance.

Files Needed

  • db_connection.py
  • Usage example file or documented examples in comments

Specifications

Functions include:

  • get_connection() - establish single database connection
  • get_connection_pool() - setup connection pooling (optional but recommended)
  • close_connection(conn) - properly close connection
  • test_connection() - verify database is accessible

Additional requirements:

  • Handle connection errors gracefully with clear error messages
  • Use environment variables or config file for credentials (host, port, database, user, password)
  • Implement context managers for clean resource handling

Connection details:

  • Host: localhost
  • Port: 5432
  • Database: daq_data
  • User: fsae

Deliverable

Submit working connection functions with usage examples. Test using the verification command from the setup guide and ensure connections work properly.

Metadata

Metadata

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