Skip to content

Commit

Permalink
feat: flask db connector
Browse files Browse the repository at this point in the history
  • Loading branch information
ysj0226 committed Sep 14, 2022
1 parent dcb0e6e commit bab03ae
Show file tree
Hide file tree
Showing 24 changed files with 3,312 additions and 1 deletion.
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,13 @@ coverage
packages/frontend/public/datasets/*

*service.json
*.db
*.db

for_test/
sasl-0.3.1-cp310-cp310-win_amd64.whl
__pycache__/
.idea/
connect.db
not_sqlalchemy/
run_flask_app.bat
venv
7 changes: 7 additions & 0 deletions apps/connector/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
for_test/
sasl-0.3.1-cp310-cp310-win_amd64.whl
__pycache__/
.idea/
connect.db
not_sqlalchemy/
run_flask_app.bat
5 changes: 5 additions & 0 deletions apps/connector/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# connector
use sqlalchemy to connect database.

It uses a method similar to Superset, and you can refer to its reference documentation.
https://superset.apache.org/docs/databases/installing-database-drivers/
36 changes: 36 additions & 0 deletions apps/connector/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from flask import Flask

from bp import bp_Druid, bp_Drill, bp_Athena, bp_Clickhouse, bp_Oracle, bp_Sqlite, bp_SQLserver, bp_Doris, bp_Redshift, bp_Mysql, bp_Impala, bp_Kylin, bp_SparkSQL, bp_Postgres
from bp import bp_database
from database import init_db
from database import db_session

app = Flask(__name__)


@app.route('/')
def hello_world(): # put application's code here
return 'Hello World!'


@app.route("/ping")
def ping():
return {
"success": True
}


@app.teardown_appcontext
def shutdown_session(exception=None):
db_session.remove()


# 注册蓝图
app.register_blueprint(bp_database.bp)


init_db()

if __name__ == '__main__':
# init_db()
app.run(host='0.0.0.0')
2 changes: 2 additions & 0 deletions apps/connector/bp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# 2022/9/5
# 17:57
Loading

0 comments on commit bab03ae

Please sign in to comment.