Author: hjlarry
Version: 0.0.5
Type: tool
Repo: https://github.com/hjlarry/dify-plugin-database
Feature Request: issues
中文文档 README_CN.md
The sql_execute tool can run any SQL query; for enhanced security, always use a read-only database account.
A database tool make it easy to query data from existing databases.
You can get different format of data, like json, csv, yaml, xlsx, html, md etc. Also support use a url to get those data.
1. Input a databaseURI for Authorization. Now support mysql, postgresql, sqlite, sqlserver, oracle, example format:
mysql+pymysql://root:123456@localhost:3306/test
postgresql+psycopg2://postgres:123456@localhost:5432/test
sqlite:///test.db
mssql+pymssql://<username>:<password>@<freetds_name>/?charset=utf8
oracle+oracledb://user:pass@hostname:port[/dbname][?service_name=<service>[&key=value&key=value...]]Note:: this plugin always run in a docker, so the
localhostalways means docker internal network, tryhost.docker.internalinstead.
The OUTPUT FORMAT is used to specify the format of the output data. If you don't specify it, the default format is json and will output in the json variable of workflow node. md will output in the text variable, other format will create file and output in the files variable.
If you input the DB URI field, it will overwrite the default authorization uri, so this will be useful if you want to use different databases in the same workflow.
This tool will use the default prompt here to generate a sql query. If you specify the TABLES field, it will only get those tables' schema into the LLM context.
If the Text to SQL tool can't generate a helpful sql query, you can use this tool to get the schema of tables, then use the schema orginze with your own prompt or other information to a LLM node to generate a helpful sql query.

The table name is always csv, the column name is the csv file's first line. It support output json and md.
example url request format:
curl -X POST 'https://daemon-plugin.dify.dev/o3wvwZfYFLU5iGopr5CxYmGaM5mWV7xf/sql' -H 'Content-Type: application/json' -d '{"query":"select * from test", "format": "md"}'- support get more table info of
get table schematool - support special
schemaofget table schematool
- support
within sql query - fix
text2sqlgenerate double quotes sql string - fix
too many clients already - add connect option of sqlalchemy
- change the
db_uriof authorization to an optional field - add a
Get Table Schemato directly response the schema of tables - add a
CSV Querytool to execute a sql query from a csv file - fix
oracleauthorization can't runselect 1
- support
sqlserver,oracleconnection - change
db_urlto a llm format, so that user can use a environment variable of workflow to set the database uri - fix in a agent app,
sql_executetool only response the first result - migrate the table schema info of the
text2sqltool to a user prompt, to prevent system prompt too long then response nothing
- add
cryptographyto requirements.txt to support mysql 8.1 sha256 link - remove database uri setting of the endpoint
- add a
db_urito support link to multiple databases - change the
outputof sql_execute tool to a form format - change the
tablesof text2sql tool to a llm format - fix sql query being converted to lowercase issue

