Skip to content

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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