Spaces:
Running
Running
| #!/usr/bin/env python3 | |
| """ | |
| Test connection string formation with URL encoding | |
| """ | |
| from urllib.parse import quote_plus | |
| # Test password encoding | |
| password = "BookMyService7" | |
| encoded = quote_plus(password) | |
| print("Password Encoding Test:") | |
| print(f" Original: {password}") | |
| print(f" Encoded: {encoded}") | |
| print(f" Same? {password == encoded}") | |
| # Build connection strings both ways | |
| user = "trans_owner" | |
| host = "ep-sweet-surf-a1qeduoy.ap-southeast-1.aws.neon.tech" | |
| port = "5432" | |
| database = "cuatrolabs" | |
| # Without encoding | |
| uri_plain = f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{database}" | |
| print(f"\nWithout encoding:\n {uri_plain}") | |
| # With encoding (like working module) | |
| uri_encoded = f"postgresql+asyncpg://{user}:{encoded}@{host}:{port}/{database}" | |
| print(f"\nWith encoding:\n {uri_encoded}") | |
| print(f"\nSame? {uri_plain == uri_encoded}") | |
| # Test with special characters | |
| special_password = "Pass@word#123" | |
| special_encoded = quote_plus(special_password) | |
| print(f"\n\nSpecial Character Test:") | |
| print(f" Original: {special_password}") | |
| print(f" Encoded: {special_encoded}") | |
| print(f" Different? {special_password != special_encoded}") | |