File size: 1,147 Bytes
3f2d4aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/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}")