# Fetch Meta From Kb

> Fetch recent `journals` rows directly from PostgreSQL and return a JSON array containing `doi`, `…

Fetch recent `journals` rows directly from PostgreSQL and return a JSON array containing `doi`, `title`, `abstract`, and `date` (filtered by rolling `DAYS` on `created_at`). Use when users need raw paper payloads for downstream processing without LLM filtering or hotspot report generation.

- Page: https://ss33.ai/skills/tiangong-ai/fetch-meta-from-kb-2418606260
- Publisher: tiangong-ai
- Category: [Data & Analytics](https://ss33.ai/skills/category/data-and-analytics-m1r3i9) › [Databases & SQL](https://ss33.ai/skills/category/data-and-analytics-m1r3i9/databases-and-sql-f7srkv)
- License: MIT
- Source: https://github.com/tiangong-ai/agent-skills/blob/5e692461708a4e02c1012086a59d2bd75da99673/fetch-meta-from-kb/SKILL.md

## Skill

SKILL.md: https://ss33.ai/api/v1/ss33/download/tiangong-ai/fetch-meta-from-kb-2418606260

# Fetch Meta from KB

## Workflow

1. Read DB env vars from `.env` or process env: `KB_DB_HOST`, `KB_DB_PORT`, `KB_DB_NAME`, `KB_DB_USER`, `KB_DB_PASSWORD`.
2. Query `journals` where `created_at >= now_utc - DAYS`, ordered by `created_at DESC`, selecting only `doi`, `title`, `abstract`, `date`.
3. Return/write JSON array records with exactly these fields: `doi`, `title`, `abstract`, `date`.

## Script

Run:

```bash
cd fetch-meta-from-kb
python3 scripts/fetch_meta_from_kb.py --days 7 --output selected-abstract.json
```

Env example:

```dotenv
KB_DB_HOST=<HOST>
KB_DB_PORT=5432
KB_DB_NAME=<DATABASE>
KB_DB_USER=<USER>
KB_DB_PASSWORD=<PASSWORD>
```

## Output Rules

- Return UTF-8 JSON.
- Keep each item as: `doi`, `title`, `abstract`, `date`.
- Do not output DB credentials.
