Skip to content

Improve Database Connection Security by Safely Encoding Credentials with quote_plus #279

@Ojasp21

Description

@Ojasp21

Is your feature request related to a problem?

  • Yes, it is related to a problem

Describe the feature you'd like

🌟 Feature Description

Enhance the database connection setup by safely encoding sensitive credentials (such as the database password) using urllib.parse.quote_plus. This ensures that special characters in credentials do not break the database connection URL.

🔍 Problem Statement

Currently, database credentials are interpolated directly into the connection string:
DATABASE_URL = f"postgresql+asyncpg://{USER}:{PASSWORD}@{HOST}:{PORT}/{DBNAME}"

If the database password contains special characters like @, :, /, #, or %, the connection string becomes malformed, leading to confusing runtime errors such as:
socket.gaierror: nodename nor servname provided

This issue is hard to debug and commonly occurs with managed databases like Supabase, where passwords often include special characters.

🎯 Expected Outcome

  1. Database credentials, especially the password, are safely URL-encoded before being used in the connection string.
  2. Prevents connection failures caused by malformed URLs.
  3. Improves robustness and developer experience when configuring environment variables.

Record

  • I agree to follow this project's Code of Conduct
  • I want to work on implementing this feature

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