Skip to content

Comments

[router] add postgres databases data connector#12218

Merged
slin1237 merged 7 commits intosgl-project:mainfrom
lengrongfu:feat/add-postgres
Nov 11, 2025
Merged

[router] add postgres databases data connector#12218
slin1237 merged 7 commits intosgl-project:mainfrom
lengrongfu:feat/add-postgres

Conversation

@lengrongfu
Copy link
Contributor

@lengrongfu lengrongfu commented Oct 27, 2025

Motivation

#10341

Postgres data store provider.

Modifications

Accuracy Tests

requerment: we need a postgres database, and create a name is sql_router db.

  1. start sgl-router use this pararm
$ sglang-router  --backend openai --worker-urls http://10.20.100.240:31896 --history-backend postgres --postgres-db-url postgres://postgres:xxxxx@xxxx:xxxx/sql_router?sslmode=prefer
  1. call /api/response api
 curl -X POST "http://127.0.0.1:30000/v1/responses" \
  -H "Content-Type: application/json" \
  --data '{
    "model": "Qwen/Qwen3-0.6B",
    "input": "Tell me a three sentence bedtime story about a unicorn.",
    "safety_identifier": "test123"
  }
  1. api can success, and to check database. we can found have create table and insert response data.
image

Benchmarking and Profiling

Checklist

@slin1237 slin1237 mentioned this pull request Oct 27, 2025
3 tasks
@lengrongfu lengrongfu force-pushed the feat/add-postgres branch 4 times, most recently from b75bac5 to 52960d2 Compare October 29, 2025 16:05
@lengrongfu lengrongfu marked this pull request as ready for review October 29, 2025 16:08
@key4ng key4ng self-assigned this Oct 29, 2025
@lengrongfu
Copy link
Contributor Author

lengrongfu commented Oct 30, 2025

this ci error, i should how to fix? @slin1237 i whether miss code change?
image

@lengrongfu
Copy link
Contributor Author

@slin1237 @key4ng hi, can help review this pr, thanks ~

@github-actions github-actions bot added the dependencies Pull requests that update a dependency file label Nov 8, 2025
.ok_or("Postgres configuration is required when history_backend=postgres")?;

info!(
"Initializing data connector: Postgres (db_url: {}, pool_max: {})",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm assumnig postgres db_url contains password? if so, we should not log it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

change to: Initializing data connector: Postgres (db_url: postgres://postgres:****@127.0.0.1:3306/sql_router?sslmode=prefer, pool_max: 16)

@key4ng
Copy link
Collaborator

key4ng commented Nov 8, 2025

thanks for the pr. overall looks good to me, just need some minor changes.
In the future, we can also consider adding CI test for postgres db

Signed-off-by: rongfu.leng <lenronfu@gmail.com>
Signed-off-by: rongfu.leng <lenronfu@gmail.com>
Signed-off-by: rongfu.leng <lenronfu@gmail.com>
Signed-off-by: rongfu.leng <lenronfu@gmail.com>
Signed-off-by: rongfu.leng <lenronfu@gmail.com>
lengrongfu and others added 2 commits November 10, 2025 18:14
Signed-off-by: rongfu.leng <lenronfu@gmail.com>
pub fn validate(&self) -> Result<(), String> {
let s = self.db_url.trim();
if s.is_empty() {
return Err("is it db-url should be not empty".to_string());
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo

Suggested change
return Err("is it db-url should be not empty".to_string());
return Err("db-url must not be empty".to_string());

@slin1237 slin1237 merged commit 2fe4e69 into sgl-project:main Nov 11, 2025
50 of 58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file high priority router run-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants