使用PyDrill创建Apache Drill MySQL存储插件遇请求错误求助
Looks like the issue is with the structure of the configuration you're passing to drill.storage_update(). Let's break down what's going wrong and how to fix it:
Why You're Seeing This Error
The error message tells us that Drill's REST API expects a PluginConfigWrapper object, which only recognizes two properties: "config" and "name". But your current code is passing "type" as a top-level field instead of nesting it inside the "config" object. Additionally, your JSON has a syntax issue: enabled:true should be "enabled": true (keys need double quotes in valid JSON).
Corrected Code
Here's the fixed version of your code with proper structure and valid JSON:
drill = PyDrill(host='host', port='8047', user='xx') # Nest all plugin settings inside the "config" field, fix JSON syntax configu = { "config": { "type": "jdbc", "driver": "com.mysql.jdbc.Driver", "url": "jdbc:mysql://host:3306", "username": "xx", "password": "xx", "enabled": True } } # Pass the plugin name and the properly structured config drill.storage_update('MySQL1', configu)
Key Changes Made:
- Nested Configuration: All plugin-specific settings (type, driver, url, etc.) are now wrapped inside the
"config"object, which matches what Drill's API expects. - Valid JSON Syntax: Fixed
enabled:trueto"enabled": True(ensured all keys are quoted and boolean values are formatted correctly). If you prefer using a string instead of a Python dictionary, make sure it's properly escaped:configu = '{"config": {"type": "jdbc","driver": "com.mysql.jdbc.Driver","url": "jdbc:mysql://host:3306","username": "xx","password": "xx","enabled": true}}'
This should resolve the 400 TransportError and successfully update your MySQL storage plugin.
内容的提问来源于stack exchange,提问作者Shrinivas Deshmukh

