Skip to content

Instantly share code, notes, and snippets.

@francisco-ltech
Created December 24, 2020 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save francisco-ltech/05e944e52f7ca5c51bce927773a91dd0 to your computer and use it in GitHub Desktop.
Save francisco-ltech/05e944e52f7ca5c51bce927773a91dd0 to your computer and use it in GitHub Desktop.
Json API endpoint for Delta Lake
from deltalake import DeltaTable
from flask import request, jsonify
app = flask.Flask(__name__)
app.config["DEBUG"] = True
@app.route('/read-delta-table', methods=['GET'])
def home():
dt = DeltaTable("/tmp/delta/students-delta-table/")
pd = dt.to_pyarrow_dataset().to_table().to_pandas()
json_str = pd.to_json(orient = "records")
parsed = json.loads(json_str)
return jsonify(parsed)
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment