Skip to content

Commit 5f51378

Browse files
Adds support for MySQL port configuration
Introduces a new optional parameter for specifying the MySQL server port, defaulting to 3306. Updates connection instructions to include port information for both local and remote connections. Enhances clarity in troubleshooting steps for testing connections with the specified port.
1 parent 8973435 commit 5f51378

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

py-src/data_formulator/data_loader/mysql_data_loader.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def list_params() -> bool:
1414
{"name": "user", "type": "string", "required": True, "default": "root", "description": ""},
1515
{"name": "password", "type": "string", "required": False, "default": "", "description": "leave blank for no password"},
1616
{"name": "host", "type": "string", "required": True, "default": "localhost", "description": ""},
17+
{"name": "port", "type": "int", "required": False, "default": 3306, "description": "MySQL server port (default 3306)"},
1718
{"name": "database", "type": "string", "required": True, "default": "mysql", "description": ""}
1819
]
1920
return params_list
@@ -25,23 +26,24 @@ def auth_instructions() -> str:
2526
2627
1. Local MySQL Setup:
2728
- Ensure MySQL server is running on your machine
28-
- Default connection: host='localhost', user='root'
29+
- Default connection: host='localhost', user='root', port=3306
2930
- If you haven't set a root password, leave password field empty
3031
3132
2. Remote MySQL Connection:
32-
- Obtain host address, username, and password from your database administrator
33+
- Obtain host address, port, username, and password from your database administrator
3334
- Ensure the MySQL server allows remote connections
3435
- Check that your IP is whitelisted in MySQL's user permissions
3536
3637
3. Common Connection Parameters:
3738
- user: Your MySQL username (default: 'root')
3839
- password: Your MySQL password (leave empty if no password set)
3940
- host: MySQL server address (default: 'localhost')
41+
- port: MySQL server port (default: 3306)
4042
- database: Target database name to connect to
4143
4244
4. Troubleshooting:
4345
- Verify MySQL service is running: `brew services list` (macOS) or `sudo systemctl status mysql` (Linux)
44-
- Test connection: `mysql -u [username] -p -h [host] [database]`
46+
- Test connection: `mysql -u [username] -p -h [host] -P [port] [database]`
4547
"""
4648

4749
def __init__(self, params: Dict[str, Any], duck_db_conn: duckdb.DuckDBPyConnection):
@@ -54,7 +56,7 @@ def __init__(self, params: Dict[str, Any], duck_db_conn: duckdb.DuckDBPyConnecti
5456

5557
attatch_string = ""
5658
for key, value in self.params.items():
57-
if value:
59+
if value is not None and value != "":
5860
attatch_string += f"{key}={value} "
5961

6062
# Detach existing mysqldb connection if it exists

0 commit comments

Comments
 (0)