|
@@ -172,7 +172,8 @@ func getPythonFileAbsolutePath(edbCode string) (pythonFile string, err error) {
|
|
|
|
|
|
func getPythonFrontStr() string {
|
|
|
|
|
|
- str := fmt.Sprintf("#!/usr/bin/python\n# -*- coding: UTF-8 -*-\nimport json\n\nimport pymysql\nimport pandas as pd\n\nsql_config = {\n 'host': '%s',\n 'port': 3306,#主机号\n 'user': '%s',#账户名\n 'passwd': '%s',#密码\n 'db': '%s',\n 'charset': 'utf8mb4',\n 'cursorclass': pymysql.cursors.DictCursor\n}\n\ndb = pymysql.connect(**sql_config)\ndb.autocommit(1)\ncursor = db.cursor()\npandas_fetch_all = pd.read_sql\n\n", utils.PYTHON_MYSQL_HOST, utils.PYTHON_MYSQL_USER, utils.PYTHON_MYSQL_PASSWD, utils.PYTHON_MYSQL_DB)
|
|
|
+
|
|
|
+ str := fmt.Sprintf("#!/usr/bin/python\n# -*- coding: UTF-8 -*-\nimport json\n\nimport pandas as pd\nfrom sqlalchemy import create_engine\nfrom urllib.parse import quote_plus\nimport pytz\n\nencoded_host = quote_plus(\"%s\")\nencoded_user = quote_plus(\"%s\")\nencoded_password = quote_plus(\"%s\")\nencoded_database = quote_plus(\"%s\")\n\ndb = create_engine(f'mysql+mysqlconnector://{encoded_user}:{encoded_password}@{encoded_host}:3306/{encoded_database}')\npandas_fetch_all = pd.read_sql_query\n\n", utils.PYTHON_MYSQL_HOST, utils.PYTHON_MYSQL_USER, utils.PYTHON_MYSQL_PASSWD, utils.PYTHON_MYSQL_DB)
|
|
|
|
|
|
|
|
|
if utils.PYTHON_MONGO_HOST != `` {
|
|
@@ -207,5 +208,5 @@ func getPythonFront3Str() string {
|
|
|
|
|
|
|
|
|
func getPythonLaterStr() string {
|
|
|
- return "\n\nprint(\"result=\", result.to_json())\ndb.close()"
|
|
|
+ return "\n\nprint(\"result=\", result.to_json())\n"
|
|
|
}
|