Library
Save and organize scripts, Query Builder queries, Explore views, and file references with folders and drag-and-drop support.
The Library lets you save and organize reusable items across your projects. It supports four item types:
- Scripts - SQL snippets with connection metadata
- Query Builder queries - Full visual Query Builder state (tables, joins, filters, columns)
- Explore views - Saved data exploration configurations
- File references - Links to SQL files in your workspace
Project and Personal Scopes
Items are organized under two scopes:
- Project - Stored in
.dbcode/library/in your workspace folder. Shared with anyone who opens the project (ideal for team queries and shared scripts). - Personal - Stored in your VS Code global storage. Private to you and available across all workspaces.
Adding Items
Save from the SQL Editor
- Select SQL text in any editor
- Click the Add Script button in the Library panel toolbar (or right-click and choose Add to Library)
- Enter a name and choose Project or Personal scope
Save from the Query Builder
Click Save to Library in the Query Builder toolbar:
- First save - Prompts for a name and scope, then stores the full visual state (tables, joins, filters, columns, positions) along with the generated SQL
- Subsequent saves - Updates the saved item silently
- Save As New - Creates a copy with a new name
Drag Files from the Explorer
Drag .sql or other files from the VS Code Explorer into the Library panel. DBCode creates a file reference that opens the file when clicked. For Project scope, workspace-relative paths are stored so references work for all team members.
Organizing with Folders
Right-click on a scope root or existing folder and choose New Folder to create folders. Drag and drop items and folders to rearrange them, including moving items between Project and Personal scopes.
Opening Items
Click any item in the Library tree to open it:
- Scripts open in a new SQL Editor tab bound to the original connection
- Query Builder queries restore the full visual state in a Query Builder tab
- File references open the linked file
If the original connection is not available (for example, a shared project item from a teammate), DBCode prompts you to select a local connection.
Renaming and Deleting
Right-click any item or folder to rename or delete it. Deleting a folder removes all items inside it.
File Format
Library items are stored as plain files:
| Type | Extension | Format |
|---|---|---|
| Script | .sql | SQL with YAML frontmatter (name, connection, database) |
| Query Builder | .qb.json | JSON with builder state and generated SQL |
| Explore | .explore.json | JSON with exploration configuration |
| File reference | .file.json | JSON with the file path |
Because items are regular files, they can be version-controlled, shared, and edited outside of DBCode.
Usage Limits
- Core: Up to 2 library items (across both scopes)
- Pro & Team: Unlimited library items
Related Features
- Favorites: Bookmark database objects in the connection tree for quick access
- Query Builder: Build queries visually and save them to the Library
- Query History: Automatically track and recall executed queries