You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importjsonas_json# Create and populate a table from API datacall_tool('sql', query='CREATE TABLE IF NOT EXISTS issues (id INT, title TEXT, state TEXT)')
raw=call_tool('github_api', endpoint='/repos/owner/repo/issues?per_page=50')
issues=_json.loads(raw)
forissueinissues:
call_tool('sql', query=f"INSERT INTO issues VALUES ({issue['number']}, '{issue['title']}', '{issue['state']}')")
# Query the dataopen_count=call_tool('sql', query='SELECT COUNT(*) as cnt FROM issues WHERE state="open"')
print(f"Open issues: {open_count[0]['cnt']}")
Search and edit
# Find and fix a pattern across fileshits=call_tool('grep', pattern='http://', paths='src', glob='*.py')
forlineinhits.strip().splitlines():
filepath=line.split(':')[0]
content=call_tool('view', path=filepath)
if'http://'incontentand'https://'notincontent:
call_tool('edit', path=filepath,
old_str='http://', new_str='https://')
print(f"Fixed: {filepath}")