SQLite3 EditorThis extension allows you to edit SQLite 3 files without having to write SQL queries. Feature OverviewThis extension can be used to 📊 view and edit database contents, ⚙ view and edit table schema, and ▶️ execute SQL queries. Most of these features are not present in other VSCode extensions for SQLite, such as alexcvzz/SQLite and SQLite Viewer. Here are some videos of the main features: 📊 Viewing Database ContentsThis extension uses scrolling for browsing records, which should be more intuitive than pagination. At the same time, only the data that is currently visible on the screen is retrieved from the database, so it loads fast even on large databases. In addition, the data is automatically reloaded when the table is modified by another process. It also comes with conditional formatting, image BLOBs preview, foreign key hover, etc. 📊 Editing Database ContentsIn addition to simple UPDATEs and INSERTs shown in the recording above, you can bulk-set a value to a selection, delete multiple rows by dragging over row numbers, set a value to a cell in a foreign key column using a dropdown, edit a table via a view, etc. ⚙ Editing Table SchemaYou can edit table schemas as shown in the video. In addition to tables, you can also edit a view's name and definition. ▶️ Executing SQL QueriesYou can run arbitrary queries in the query editor. The editor supports context-aware auto-completion, syntax highlighting, hover documentation, signature help, and syntax validation. Feature DocumentationThe arrangement of the features listed in this section does not reflect any particular order. Feel free to explore each feature as per your interest. Table of Contents
Creating a DatabaseTo create a database file, simply create a file with a supported file extension, such as .db, .sqlite, or .sqlite3. The extension will automatically initialize the file as a database if it is empty and has one of the supported extensions. Editing Table Schema - Checking Table SchemaTo view the schema of the active table, click on the "Schema" button located at the top of the editor. This will open a panel displaying the table schema, indexes, and triggers. This feature supports both tables and views. The "Index" section displays an array of blue and gray boxes for each index. They represent which column the index applies to, with numbers indicating the order. For example, if you have When you hover your cursor over an index, it highlights the corresponding columns. Conversely, when you hover your cursor over the dotted text in the columns, it highlights the associated indexes in the "Schema" pane. Editing Table Schema - Changing Column DefinitionYou can change the type affinity and the constraints of a column with this feature. Editing Table Schema - Changing Column OrderYou can change the order of table columns by dragging the table header. We've tested this feature extensively, but we won't take any responsibility for possible data loss. Please ensure you check the generated query and/or create a backup before using this feature, especially if you're working with a critical database. Editing Table Schema - Creating a TableYou can access this feature by clicking on the statement at the bottom of the editor, then selecting "CREATE TABLE". The tables that can be created by this feature are limited to simpler ones. To create a complex table, such as ones with GENERATED columns or COLLATE clauses, use the query editor. Editing Table Schema - Creating an IndexYou can access this feature by either clicking the SQL statement at the bottom of the editor, right-clicking the table name in the SELECT statement, or clicking "Schema" then "Index > + Add". Editing Table Schema - Dropping a TableYou can access this feature by either clicking on the SQL statement at the bottom of the editor, or by right-clicking the table name in the SELECT statement, and then selecting "DROP TABLE". Editing Table Schema - Renaming a TableTo rename a table, right-click the table name in the SELECT statement, and then select "Rename Table". File AssociationsThis extension recognizes Importing and Exporting Data in CSV, JSON, or SQLBy clicking the "Other Tools..." button, you can access various features, including CSV, JSON, and SQL imports and exports.
These import and export features rely on a helper program bundled with this extension. You can check the available options by using In-Memory DatabasesYou can connect to an in-memory database using Opening the Database in a Command Line ShellThis feature opens an integrated terminal in VSCode, initialized with the command Query Editor - OverviewTo access the query editor, click the "Query Editor" button. The line comment at the first line of the query editor indicates the linked database. If it is deleted, the query editor will disconnect from the database. Any files that start with There are three ways to execute statements in the query editor:
The "Execute" button shown above a transaction ( Due to the limitation of the current mechanism to reload the table, there may be a slight delay between the execution of a statement and the updates to the table. Query Editor - Document FormattingYou can format queries by selecting "Format Document" in the command palette or by pressing Shift+Alt+F (or ⇧ ⌥ F on Mac). This feature employs sql-formatter to format queries.
You can adjust formatting options with the configurations under Query Editor - Executing a Part of Common Table Expression (CTE)In the query editor, "Select" buttons are displayed for each CTE. This enhances the ease of creating complex queries involving CTEs. Query Editor - Syntax ValidationThe query editor identifies syntax errors in SQL statements by preparing each statement in an isolated database connection and catching compilation errors. However, due to the nature of this method, certain errors might not be detected, such as those within PRAGMA statements or references to non-existent tables. Table View - Auto ReloadingWhen the 'Auto Reload' button is activated, the editor will automatically refresh the table whenever there are updates. Table View - Conditional FormattingConditional formatting colorizes table cells by their values. You can use this feature by right-clicking a table column then "Colorize (Conditional Formatting)". Table View - Displaying and Jumping to the Definition of Foreign KeysYou can view the source record of a cell in a column that is under a foreign key constraint by hovering the cursor over the cell. If you want to jump to the source record, use the context menu item. Table View - Drop Multiple TablesYou can quickly drop multiple tables with the multiselect mode in the table selector. You can enter the multiselect mode by right-clicking on a table name in the dropdown menu or by pressing Alt+Click (or ⌥ click on Mac) on a dropdown item. Table View - Editing GENERATED ColumnsGENERATED columns can be edited just like any other columns. Committing a change updates the table schema. Table View - Entity-Relationship DiagramIf the database contains foreign keys or views, the table selector will display the entity-relationship diagram alongside the list of tables. Clicking on an entity opens the corresponding table. You can display the columns and values in the first row of a table by right-clicking on the table name or pressing Ctrl+Click (or ⌘ click on Mac). Table View - Filtering and Sorting DataThe find widget shown in the image below allows you to quickly filter records by searching for text matches across all columns, just like the one in VSCode. For more advanced usage, you can also use the regular expression, whole word, and case-sensitivity switches. You can access this feature by pressing the "Find" button in the editor or pressing Ctrl+F (or ⌘ F on Mac). Column filters allow you to filter records based on a specific value in the chosen column. To use this, right-click on a table column header. Alternatively, you can also set a filter via the context menu on cells. To sort records by a specific column, simply click on the column name. You can also sort the table from the context menu on the column name. Table View - Finding Foreign Keys Referencing a ValueTo find the foreign keys referencing a value, select a cell and click Table View - Git-Diff SupportWhen you open a database from the source control view, you will see a side-by-side comparison of two versions of the database. To display the differences between the two versions, click the "Compare with Local File" button. Depending on the size of the database, it may take several seconds or minutes for the differences to appear. If locking the databases is a problem for your use-case, you should avoid using this feature. Table View - Group by ValueYou can group records by a column with this feature. To group a column, right-click on a column header then select "Group by Value". To cancel the grouping, click the icon on the column header. Table View - Inserting Data from CSVYou can insert CSV into an existing table by clicking the SQL statement at the bottom of the editor then selecting "Bulk Insert". This feature inserts CSV data into the table. Each CSV column is encoded as TEXT, but if the table column has a data type (column affinity), SQLite will cast it to the appropriate type. For example, if a column is defined as "column1 INTEGER," then the CSV values in that column will be cast as an integer. Table View - Jumping to a Table or a RowWhen the extension's editor is active, you can use the Go to Table/Row command to navigate to a specific table and/or row. The Ctrl+G keybinding (or ⌘ G on Mac) is assigned to this command. Table View - Multi-SelectionUPDATE and DELETE statements support multi-selection. To select multiple cells, you can either drag over the cells, click a cell with the alt key pressed, or press the Shift + Arrow keys while a cell is selected.
You can perform actions other than editing data by right-clicking on the selection. Table View - Pop-Out EditorThis feature is available when the configuration When enabled, you can open an embedded textarea in a new tab by either:
The Alt+P shortcut selects an editor based on the following rules:
Setting Table View - Resizing ColumnsYou can resize columns by dragging the right edge of the column header. Alternatively, to adjust the width to the content, you can use the "Autofit Column Width" button in the context menu. Table View - Resizing RowsYou can resize rows by dragging the lower edge of a row's number. Table View - Selecting a TableYou can switch between tables by clicking a table name in either the editor or the explorer. Table View - TabsAdding Using Run-Time Loadable SQLite ExtensionsThe configuration setting "sqlite3-editor.connection.runtimeLoadableExtensions" allows you to specify run-time loadable extensions that will be loaded with every SQLite connection opened by this extension. For example, to load SpatiaLite, follow these instructions:
Using User Compiled SQLiteSince this extension statically links SQLite to a component built with Rust, you need to rebuild the component to use a non-standard version of SQLite. For example, if you want to add the compilation flag SQLITE_OMIT_DEPRECATED to SQLite to exclude deprecated features, follow these instructions:
Please note that making changes like this could cause issues with future updates to the extension. Therefore, we recommend turning off automatic updates for this extension. Frequently Asked Questions
ConfigurationsThis document does not cover all of the configuration options. Please search "sqlite3-editor" in the VSCode's settings tab for further information. sqlite3-editor.connection.setupQueriesThis configuration specifies SQL statements that are executed immediately after connecting to a database. The keys are case-sensitive regular expressions used to match the file URI, and the values are corresponding SQL statements to be executed. In case multiple patterns match the same URI, only the first item will be used. Commands that are available in the SQLite's CLI, including For example, to execute
sqlite3-editor.connection.runtimeLoadableExtensionsThis configuration loads run-time loadable extensions immediately after connecting to a database, using the The keys are case-sensitive regular expressions used to match the file URI, and the values are the list of runtime-loadable extensions to be loaded. In case multiple patterns match the same URI, only the first item will be used. The runtime-loadable extensions are loaded before executing the setup queries specified in For example, to load the
sqlite3-editor.pragma_foreign_keyThis configuration controls whether the enforcement of foreign key constraints is enabled. This configuration has the same effect as setting sqlite3-editor.maxHistoryEntriesBy default, this extension stores the last 500 SQL queries executed in the query editor. You can view them using sqlite3-editor.comment.filepathBy default, the "comment" feature, accessible from the schema pane, writes descriptions about database tables to a file with the extension ".docs.md" located next to the database table. This configuration changes the file path of the comment file. SyntaxThe value can begin with one of the following prefix variables. If the value lacks these prefix variables, it is interpreted as an absolute path.
After the prefix or the first segment (e.g., "C:\" or "/") of the absolute path, the following variables can be used anywhere and any number of times:
The configuration value must resolve to a filename that ends with ".md" after variable replacement. Slash and backslash characters ("/", "\") will be replaced with appropriate ones for the current platform. Supported EnvironmentsMinimum Supported VSCode Version: 1.70.0 (July 2022) Supported Operating Systems:
*1 are fallbacks for when glibc is not available, such as on Alpine Linux, but they do not support SQLite run-time loadable extensions because libc (musl) is statically linked. LicenseOpen Source LicensesThe NoticeSQLite3 Editor Copyright (C) 2024 https://github.com/yy0931 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |