Arghyahub65 downloadsLets you use Postgresql database inside Obsidian and manage queries.
Run PostgreSQL queries directly from your Obsidian notes. Connect to one or more databases, write SQL in fenced code blocks, execute queries in place, and browse results in a side panel — all without leaving your vault.
Postgres DB is a desktop-only Obsidian community plugin by Arghyahub.
postgresql:// connection string to fill the connection form automatically.sql blocks get syntax highlighting, a run button, copy button, and a connection picker.alias.column), and SQL keywords based on the active database schema.pg client and Electron APIs not available on mobileDownload main.js, manifest.json, and styles.css from the latest release.
Copy them into your vault:
<Vault>/.obsidian/plugins/pg/
Reload Obsidian and enable Pg under Settings → Community plugins.
Open the PostgreSQL connections view using either:
Fill in your connection details (or paste a postgresql:// URL and select Fill from URL), then select Test connection and Save.
The first saved connection becomes the default automatically. You can change the default from the saved connections list or from any SQL block's database picker.
Create a fenced SQL code block in any note:
```sql
SELECT id, title, created_at
FROM posts
ORDER BY created_at DESC
LIMIT 10;
```
In Reading view or Live Preview, the block shows a toolbar with:
| Control | Action |
|---|---|
| Database button | Switch the default connection for this vault session |
| Refresh | Reload table/column schema for autocomplete |
| Copy | Copy the SQL to your clipboard |
| Play | Execute the query |
Results appear in the SQL results panel on the right. Use the download icon to export rows as CSV.
In Source mode or when editing a SQL block in Live Preview, start typing to get suggestions:
users. or u.)Schema is loaded automatically when you set a default connection. Select the refresh icon on a SQL block to reload it after schema changes.
Each connection supports:
| Field | Description |
|---|---|
| Name | Optional display label |
| Host | Server hostname or IP |
| Port | Default 5432 |
| Database | Database name |
| Username / Password | Credentials (stored locally in plugin data) |
| SSL mode | disable, allow, prefer, require, verify-ca, verify-full |
| Timeout | Connection timeout in milliseconds (default 10000) |
Connection credentials are saved in Obsidian's plugin data store on your machine. They are not sent anywhere except to the PostgreSQL server you configure.
The SQL results panel shows:
Click any non-null cell to open a popup with the full value. Use the download button to save results as <note-name>-result-<timestamp>.csv in your Downloads folder.
| Command | Description |
|---|---|
| Open PostgreSQL connections | Open the connection management view |
git clone https://github.com/Arghyahub/obsidian-postgres-plugin.git
cd obsidian-postgres-plugin
npm install
For local testing, place the project folder inside your vault:
<Vault>/.obsidian/plugins/pg/
| Command | Description |
|---|---|
npm run dev |
Build in watch mode (recompiles on save) |
npm run build |
Production build (type-check + bundle) |
npm run lint |
Run ESLint |
After building, reload Obsidian to pick up changes.
src/
main.ts # Plugin entry point
settings.ts # Settings interface and tab
views/ # Connection manager and query result panels
editor/ # SQL code blocks, autocomplete, editor extensions
ui/ # Dropdowns and popups
utils/ # Connection, query, schema, and export helpers
types/ # TypeScript interfaces
Update minAppVersion in manifest.json if needed.
Bump the version:
npm version patch # or minor / major
This updates manifest.json, package.json, and versions.json.
Push the tag — the GitHub Action builds main.js and creates a draft release with the required assets.
0-BSD — see LICENSE.