sqllineage/sqllineage.py

34 lines
1.1 KiB
Python
Raw Normal View History

2025-02-05 14:18:02 +08:00
from flask import Flask, render_template, request, jsonify
from utils.sql_parse import parse_create_table_sql
from utils.log import Log
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/convert', methods=['POST'])
def convert_sql():
# 创建一个新的Log实例确保每天创建一个新的日志文件
log = Log().getlog()
sql_input = request.form['sql']
hologres_connection = request.form['hologresConnection']
log.info("SQL Input: %s", sql_input)
log.info("SQL hologres_connection: %s", hologres_connection)
try:
parsed_result=parse_create_table_sql(sql_input,hologres_connection)
result = {
'target_tables': parsed_result,
'message': 'SQL processed successfully.'
}
except Exception as e:
result = {'error': str(e)}
log.info("SQL result: %s", result)
return jsonify(result)
if __name__ == '__main__':
# 指定host和port这里使用0.0.0.0可以让服务器被外部访问
app.run(host='0.0.0.0', port=8778, debug=True)