Like the subject says, I am building a web app that decomposes an MS Access database file into its component tables (export as CSV).
The whole point is to use dcc.Upload to pass the .mdb file into the server so my ts_db.py script can parse the file and return the CSV files as exports.
However, when I use the following code, the script does not process the .mdb file like it does on my local Python interpreter:
# ======================== App Layout
upload = html.Div(
dcc.Upload(
id="upload-data",
children=html.Div(
["Drag and Drop or ", html.A("Select TestStand .mdb File to Process")]
),
style={
"width": "95%",
"height": "60px",
"lineHeight": "60px",
"borderWidth": "3px",
"borderStyle": "dashed",
"borderRadius": "10px",
"textAlign": "center",
"margin": "20px",
},
),
)
output_data = html.Div(id="output-data-upload")
app.layout = html.Div([upload, output_data])
# ======================== App Callbacks/FileIO
@app.callback(
Output("output-data-upload", "children"),
Input("upload-data", "contents"),
Input("upload-data", "filename"),
)
def import_contents(contents, filename):
"""Open TestStand database (.mdb) with user prompt"""
if contents:
content_type, content_string = contents.split(",")
decoded = base64.b64decode(content_string)
file_like_object = io.BytesIO(decoded)
db_filename = file_like_object
print(db_filename)
"""Execute core python script to decompose the TestStand database file"""
ts_db.main(db_filename)
children = [filename]
return children
Any advice or insight would be appreciated!
May peace be with you,
Ahmed