MCPcopy Index your code
hub / github.com/dataease/SQLBot / delete_ds

Function delete_ds

backend/apps/datasource/crud/datasource.py:123–142  ·  view source on GitHub ↗
(session: SessionDep, id: int)

Source from the content-addressed store, hash-verified

121
122
123async def delete_ds(session: SessionDep, id: int):
124 term = session.exec(select(CoreDatasource).where(CoreDatasource.id == id)).first()
125 if term.type == "excel":
126 # drop all tables for current datasource
127 engine = get_engine_conn()
128 conf = DatasourceConf(**json.loads(aes_decrypt(term.configuration)))
129 with engine.connect() as conn:
130 for sheet in conf.sheets:
131 conn.execute(text(f'DROP TABLE IF EXISTS "{sheet["tableName"]}"'))
132 conn.commit()
133
134 session.delete(term)
135 session.commit()
136 delete_table_by_ds_id(session, id)
137 delete_field_by_ds_id(session, id)
138 if term:
139 await clear_ws_ds_cache(term.oid)
140 return {
141 "message": f"Datasource with ID {id} deleted successfully."
142 }
143
144
145def getTables(session: SessionDep, id: int):

Callers 1

deleteFunction · 0.85

Calls 9

get_engine_connFunction · 0.90
aes_decryptFunction · 0.90
DatasourceConfClass · 0.85
delete_table_by_ds_idFunction · 0.85
delete_field_by_ds_idFunction · 0.85
clear_ws_ds_cacheFunction · 0.85
firstMethod · 0.45
execMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected