Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: flask db connector #114

Merged
merged 1 commit into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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