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

Function updateNum

backend/apps/datasource/crud/datasource.py:389–400  ·  view source on GitHub ↗
(session: SessionDep, ds: CoreDatasource)

Source from the content-addressed store, hash-verified

387
388
389def updateNum(session: SessionDep, ds: CoreDatasource):
390 all_tables = get_tables(ds) if ds.type != 'excel' else json.loads(aes_decrypt(ds.configuration)).get('sheets')
391 selected_tables = get_tables_by_ds_id(session, ds.id)
392 num = f'{len(selected_tables)}/{len(all_tables)}'
393
394 record = session.exec(select(CoreDatasource).where(CoreDatasource.id == ds.id)).first()
395 update_data = ds.model_dump(exclude_unset=True)
396 for field, value in update_data.items():
397 setattr(record, field, value)
398 record.num = num
399 session.add(record)
400 session.commit()
401
402
403def get_table_obj_by_ds(session: SessionDep, current_user: CurrentUser, ds: CoreDatasource) -> List[TableAndFields]:

Callers 2

create_dsFunction · 0.85
chooseTablesFunction · 0.85

Calls 8

get_tablesFunction · 0.90
aes_decryptFunction · 0.90
get_tables_by_ds_idFunction · 0.85
getMethod · 0.65
addMethod · 0.65
firstMethod · 0.45
execMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected