Skip to content

Feature/db conn passing - #18

Open
Petroncini wants to merge 9 commits into
devfrom
feature/db_conn_passing
Open

Petroncini wants to merge 9 commits into
devfrom
feature/db_conn_passing

Conversation

@Petroncini

Copy link
Copy Markdown
Collaborator

No description provided.

Petroncini and others added 9 commits September 29, 2026 14:55
InsightEngine now accepts an optional db_engine: a SQLAlchemy Engine built
and disposed by the caller. It is injected into the schema, code-agent and
sandbox nodes via functools.partial (same pattern already used for llm),
so it never enters the LangGraph state and is never checkpointed. This
keeps credentials out of the MemorySaver snapshot and hands connection
lifecycle/pooling to the caller instead of the library.

- code_sql: extract executar_sql_via_engine (never creates/disposes the
  engine); executar_sql_via_url now delegates to it
- schema/sandbox/code_agent: use the injected engine first, reading the
  dialect from engine.dialect.name; legacy db_path/db_config/db_url path
  is unchanged when no engine is given
- graph: only bind engine= when one is provided, so existing mocks keep
  working
- cli: --db-url now builds and disposes its own Engine and passes it in
- tests: cover schema, execution and dialect resolution via engine
Review follow-ups for the caller-owned engine:

- executar_sql_via_engine no longer leaves session state on the caller's
  pooled connections: the SQLite timeout progress handler is cleared after
  the query (it was aborting the caller's later queries with "interrupted"),
  and MySQL connections are invalidated since SET SESSION is not
  transactional. Postgres SET runs inside the auto-begun transaction and is
  rolled back on close.
- data exploration now uses the injected engine instead of opening db_path
  (which could be a different database); it is SQLite-only, so it is
  skipped for other dialects.
- enrich no longer writes the db_path-keyed schema cache when the schema
  came from an engine or db_url, which overwrote the local SQLite cache
  with another database's schema.
- replace a test that could not fail with regression tests for the above.
execução de dialetos por drivers diretos (PostgreSQL e MySQL
O script agora cria uma Engine SQLAlchemy read-only por banco, passa via
db_engine para a InsightEngine e a descarta ao final.
Mesmo padrão do script do Spider 2: uma Engine SQLAlchemy read-only por
banco, passada via db_engine e descartada ao final.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants