Black Lives Matter. Please consider donating to Black Girls Code today.

Creating Dash Cytoscape elements from data tables

I am requesting assistance in the displaying of network using dash and cytoscape. My network node and edges are defined in a table and I can actively display the table in dash. My question is related to how do I transition this node and edge information into a dash-cytoscape element list for charting. The following is my example code:

cnxn = pyodbc.connect(“Driver={};ConnectionType=Direct;HOST={};PORT={};AuthenticationType=Plain;UID={};PWD={}”.format(driver, host,port,uid,pwd),autocommit=True)

sql = ‘’‘SELECT “Switch Name”, “Remote System Name” FROM “@wgreen”.“mapping-lldp-nodes” WHERE “Remote System Name” LIKE ‘%1400%’ ‘’’

df = pd.read_sql(sql,cnxn)


app = dash.Dash(name)
app.layout = dash_table.DataTable(
columns=[{“id”: i, “name”: i} for i in df.columns],

if name == ‘main’:
app.run_server(debug=True, port=8082)