Skip to content

changes to add an sql-agent example/tutorial#428

Merged
gladwig2 merged 6 commits into
mainfrom
geoff/sql-agent
Sep 10, 2025
Merged

changes to add an sql-agent example/tutorial#428
gladwig2 merged 6 commits into
mainfrom
geoff/sql-agent

Conversation

@gladwig2

@gladwig2 gladwig2 commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

Documentation update

Overview

added sql-agent example.

Preview: https://langchain-5e9cc07a-preview-geoffs-1757520005-6d096a8.mintlify.app/oss/python/langchain/sql-agent

Type of change

  • New documentation page
  • Update existing documentation
  • Fix typo, bug, broken link, or formatting issue
  • Remove outdated content
  • Other (please describe):

Related issues/PRs

  • GitHub issue:
  • Feature PR:
  • Linear issue:
  • Slack thread:

Checklist

  • I have read the contributing guidelines
  • I have tested my changes locally using docs dev
  • All code examples have been tested and work correctly
  • I have used root relative paths for internal links
  • I have updated navigation in src/docs.json if needed
  • I have gotten approval from the relevant reviewers
  • (Internal team members only / optional) I have created a preview deployment using the Create Preview Branch workflow

Additional notes

@github-actions

github-actions Bot commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

Preview ID generated: preview-geoffs-1757438045-6cc35aa

@github-actions

github-actions Bot commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

Preview ID generated: preview-geoffs-1757439890-086d40f

@github-actions

github-actions Bot commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

Preview ID generated: preview-geoffs-1757455150-bd18afa

@github-actions

Copy link
Copy Markdown
Contributor

Preview ID generated: preview-geoffs-1757515721-3101d4b

@github-actions

Copy link
Copy Markdown
Contributor

Preview ID generated: preview-geoffs-1757520005-6d096a8

Comment on lines +89 to +127
:::python
```python
import requests, pathlib

url = "https://storage.googleapis.com/benchmarks-artifacts/chinook/Chinook.db"
local_path = pathlib.Path("Chinook.db")

if local_path.exists():
print(f"{local_path} already exists, skipping download.")
else:
response = requests.get(url)
if response.status_code == 200:
local_path.write_bytes(response.content)
print(f"File downloaded and saved as {local_path}")
else:
print(f"Failed to download the file. Status code: {response.status_code}")
```
:::
:::js
```js
import { existsSync } from "node:fs";
import fs from "node:fs/promises";
import path from "node:path";

const url = "https://storage.googleapis.com/benchmarks-artifacts/chinook/Chinook.db";
const localPath = path.resolve("Chinook.db");

if (existsSync(localPath)) {
console.log(`${localPath} already exists, skipping download.`);
} else {
console.log(`Downloading ${url} ...`);
const resp = await fetch(url);
if (!resp.ok) throw new Error(`Failed to download DB. Status code: ${resp.status}`);
const buf = Buffer.from(await resp.arrayBuffer());
await fs.writeFile(localPath, buf);
console.log(`File downloaded and saved as ${localPath}`);
}
```
:::

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need these code examples? is it more intuitive to just tell them download the db and put it in the same directory as the script?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. Sort of distracting.
I'm inclined toward keeping it as it just takes care of one step for the user.
I could/should collapse it so that a reader won't be distracted - only the few that really dig into it will find it.

In general, I think we might want to think about having a git-repo for examples as opposed to this.
The doc would go over highlights and important points, but the repo would have all the details -including a 'utilities' file where you could store things like this.

Comment thread src/oss/langchain/sql-agent.mdx Outdated
Comment on lines +151 to +154
const datasource = new DataSource({ type: "sqlite", database: localPath });
const db = await SqlDatabase.fromDataSourceParams({ appDataSource: datasource });

const SCHEMA = await db.getTableInfo();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the record I don't think we've touched these sql primitives for a year or so

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

@github-actions

Copy link
Copy Markdown
Contributor

Preview ID generated: preview-geoffs-1757524592-dfda4b2

@gladwig2
gladwig2 merged commit a13baed into main Sep 10, 2025
11 checks passed
@gladwig2
gladwig2 deleted the geoff/sql-agent branch September 10, 2025 17:22
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.

3 participants