Connecting to ScramDB
ScramDB provides a PostgreSQL-compatible interface, allowing you to connect using standard SQL clients and tools.
Connection Details
When running the platform locally using the provided Docker Compose setup:
- Host:
localhost
(or the IP address of your Docker host if not running locally) - Port:
5433
- User: Any username (Authentication is currently disabled by default in the Docker setup)
- Password: Not required (Authentication is currently disabled)
- Database: You can connect without specifying a database, or use a default like
postgres
orscramdb
.
Note: The default Docker Compose configuration for ScramDB includes the --pg-no-auth
flag, which disables authentication checks. In a production environment, you would typically configure authentication.
Connection Examples
Using psql
(Command-Line Tool)
psql -h localhost -p 5433 -U anyuser
You can omit the -U
flag if your system username matches a potential database user, or simply connect without specifying a user if allowed:
psql -h localhost -p 5433
Using DBeaver (GUI Tool)
- Click “New Database Connection”.
- Select “PostgreSQL”.
- On the “Main” tab:
- Host:
localhost
- Port:
5433
- Database: (Optional)
scramdb
or leave blank - Authentication: Select “No Auth” or leave Username/Password blank.
- Host:
- Click “Test Connection” (optional).
- Click “Finish”.
Using Python (psycopg2)
import psycopg2
try: # Note: No user/password needed due to --pg-no-auth flag conn = psycopg2.connect( host="localhost", port="5433", # user="your_user", # Not needed if auth disabled # password="your_password", # Not needed if auth disabled # dbname="scramdb" # Optional ) print("Connection successful!")
# Example: Execute a query cur = conn.cursor() cur.execute("SELECT version();") db_version = cur.fetchone() print(f"Server Version: {db_version[0]}")
cur.close() conn.close()
except psycopg2.OperationalError as e: print(f"Unable to connect!\n{e}")
Adjust the connection parameters based on your specific client or programming language library, using the host and port details provided above.