GithubHelp home page GithubHelp logo

alexcovizzi / vscode-sqlite Goto Github PK

View Code? Open in Web Editor NEW
196.0 10.0 22.0 8.35 MB

VSCode extension to explore and query SQLite databases.

License: Apache License 2.0

TypeScript 98.98% JavaScript 1.02%
vscode sqlite

vscode-sqlite's Introduction

vscode-sqlite (unmaintained)

Note: The project has been unmaintained since mid 2022 and it will not receive any new updates. The extension should still work in most cases, however the embedded SQLite is out of date and it may not have some of the newer features, in that case you can provide your own SQLite (see sqlite.sqlite3 setting).

VSCode extension to explore and query SQLite databases.

static/sqlite_workflow_1

Requirements

Windows, MacOS: No requirement.

Linux: If the extension is not working out-of-the-box, it may be necessary to install sqlite3 in your system (on Ubuntu: sudo apt install sqlite3)

Note: The extension includes precompiled binaries for the SQLite CLI (used to execute queries), in case the included binaries do not work (or if you want to use your own binaries) you need to provide the path/command to the sqlite3 CLI executable in the setting sqlite.sqlite3.

Features

  • Query SQLite databases and view results in a table (also supports dot commands like .tables, .schema, ecc).

  • Export query results to json, csv and html.

  • Sidebar explorer: list databases, tables, views and columns.

  • Autocompletion for SQLite keywords, table and views names, column names (autocompletion is available for an SQL document once its bound to a database, to bind an sql document to a database use the command SQLite: Use Database)

  • Grammar support for SQLite keywords. This is available for documents with language sqlite. You can mark a document as an sqlite document adding -- sqlite in the first line.

Commands

  • SQLite: New Query   Create a new untitled sqlite file.

  • SQLite: Run Query   Execute query script in the editor.

  • SQLite: Quick Query   Choose a database and execute a query without creating a new document.

  • SQLite: Use Database   Bind current sql document to the selected database.

  • SQLite: Open Database   Open the selected database in the sqlite explorer.

  • SQLite: Close Database   Remove the selected database from the sqlite explorer.

  • SQLite: Refresh Databases   Refresh databases open in the sqlite explorer.

  • SQLite: Show output   Show the extension's output channel.

  • SQLite: Change Workspace Trust   Change the trust of this workspace. By default every workspace is untrusted for security reasons.

Settings

  • "sqlite.sqlite3": string   sqlite3 command or CLI executable path (this setting is disabled for untrusted workspaces)

  • "sqlite.logLevel": string   Set output channel log level (DEBUG, INFO, WARN, ERROR).

  • "sqlite.recordsPerPage": number   Number of records to show per page. (-1 to show all records).

  • "sqlite.databaseExtensions": string[]   The file extensions recognized as SQLite database.

  • "sqlite.setupDatabase": { [path]: { sql: string[] } }   Custom query to run when opening a database.

    In each entry the key is the path of the database and the value is an object with the SQL queries to run (in order).

    For example:

    { "./users.db": { "sql": ["PRAGMA foreign_keys = ON;"] } }

    Means that every time the database users.db is opened, the SQL query PRAGMA foreign_keys = ON; is executed.

Thanks to the Contributors!

mandel59 (Ryusei YAMAGUCHI), LokiSharp (LokiSharp), MrCodingB(MrCodingB)

vscode-sqlite's People

Contributors

alexcovizzi avatar dependabot[bot] avatar lokisharp avatar mandel59 avatar mrcodingb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-sqlite's Issues

VSCode can't install the extension on MacOS

VSCode can't install the extension by clicking the install button. It shows the "Install manually" button instead and then offers to install from the VSIX file.

The installation from the VSIX subsequently also fails. More precisely it seems to succeed but after reloading VSCode the commands don't show up in the command palette and the extension shows a blue "Reload" button in the list of installed extensions (which I clicked a few times but it never succeeds).

VSCode version 1.21.1 (79b44aa704ce542d8ca4a3cc44cfca566e7720f1)
OS version: macOS High Sierra 10.13.3 (17D102)
Extension version: 0.1.2

Resources in WebView are not loaded in dev host environment on Windows

In deb host environment, resources in WebView are not loaded although the SQLite tab has been open:
000
VS Code is installed at C:\Users\mande\AppData\Local\Programs\Microsoft VS Code, and my dev repository is put at D:\mande\dev\vscode-sqlite.

Developer Console shows "failed to load resource" errors:
001

In the following line, the value of this.resourcesPath is "d:\mande\dev\vscode-sqlite\out\resultview\htmlcontent" in my dev environment.

localResourceRoots: [Uri.parse(this.resourcesPath).with({scheme: this.resourceScheme})]

So Uri.parse parses it as:

  • schema: "d:"
  • path: "\mande\dev\vscode-sqlite\out\resultview\htmlcontent"

005

And then the schema is rewriten, so the result is "vscode-resource:\mande\dev\vscode-sqlite\out\resultview\htmlcontent", which misses the drive letter d:.

exec only selected text

Exec only selected text (also if it's inside a comment), so we don't have to reedit script.

exec only "SELECT * FROM sqlite_master;"
schermata 2018-07-25 alle 14 15 17

exec only "select * from tokens;"
schermata 2018-07-25 alle 14 11 51

[feature-request] Add support for SQLCipher

From the GitHub page:

SQLCipher extends the SQLite database library to add security enhancements that make it more suitable for encrypted local data storage such as on-the-fly encryption, tamper evidence, and key derivation. Based on SQLite, SQLCipher closely tracks SQLite and periodically integrates stable SQLite release features.

Support could be added by including the required SQLCipher bins, and adding a 'provider selector' when opening databases.

HTML in table is rendered

I have a table that contains code snippets, including HTML code snippets. When I query that table such a code snippet of HTML is rendered, where I would love to see the original HTML.

Simply adding a html encode could probably already solve the issue.

html-snippets

This is the output when I use the sqlite3 cli:

sqlite> SELECT * FROM Snippets WHERE SnippetID BETWEEN 32 and 43;
32|3|Form - Button|<input type="button" name="|" id="" value="" />|0|0|0|
33|3|Form - Checkbox|<input type="checkbox" name="|" id="" value="" checked="checked" />|0|0|0|
34|3|Form - Hidden|<input type="hidden" name="|" id="" value="" />|0|0|0|
35|3|Form - Password|<input type="password" name="|" id="" size="20" maxlength="30" />|0|0|0|
36|3|Form - Radio|<input type="radio" name="|" id="" value="" checked="checked" />|0|0|0|
37|3|Form - Text|<input type="text" name="|" value="" id="" maxlength="30" />|0|0|0|
38|3|Form - Textarea|<textarea rows="2" cols="40" name="" id="">|</textarea>|0|0|0|
39|3|Form - Submit|<input type="submit" value="|" />|0|0||
40|3|Form - Submit Image|<input type="image" src="|.png" alt="Submit" />|0|0||
41|3|Form - Select|<select name="" id="">
        <optgroup label="">
                <option value="" selected="selected">|</option>
        </optgroup>
</select>|0|0|0|
42|3|Form - Label|<label for="">|</label>|0|0|0|
43|3|Heading 1|<h1>|</h1>|0|0||
sqlite>

If you want to test with the database, you can find it at https://github.com/ffes/nppsnippets/tree/master/misc

Allow drag-drop from Explorer Side Bar

Allow to drag and drop a table or column to any edit window. The name of the selected item should be inserted at the cursor location. This way it is easy to use those names in a source file.

[feature-request] Add support for in-memory database

When selecting an SQLite database from the status bar, could the list always include an item for an in-memory database?

SQLite accepts the special path :memory: to open a transient memory-only database. Its contents will be lost when the database connection is closed. This makes it ideal for quick testing of a complete SQL script, without having to save stuff to disk. Also, I often use this as a starting point for attaching several other databases, each with their specific alias.

Database not closed?

When I do first:
SQLite: Open Database in Explorer Open the selected database in the sidebar explorer.

I see in my folder that 2 temporary files are generated:
-shm and -shm

And then:
SQLite: Close Explorer Database Remove the selected database from the explorer.

I see in my folder that the 2 temporary files are still present.
When I use a program like MesaSQLITE and close a database, these files do disappear.

New Query from table

When I right-click a table, it has an option Show Table. Could you add an option New Query as well?

Ideally it would open a query like this:

SELECT column1
     , column2
     , column3
FROM table

but simply SELECT * FROM table would already be helpful

Table PK info in ColumnItem

When retrive column infos (file src/explorer/explorerTreeProvider.ts line 82), PK property could be ">0", not "==1" if table has two column for primary key

schermata 2018-06-28 alle 11 37 44

EXAMPLE:

CREATE TABLE employees ( company_id TEXT , emp_id TEXT , company_sbj_id TEXT , subject_id TEXT , hire_date INTEGER , resign_date INTEGER , sync_stamp INTEGER , **PRIMARY KEY (company_id,emp_id)** )

schermata 2018-06-28 alle 11 36 03

Can't open DB in the explorer

Hi,
Here is an issue I came across.
At the very first time I can open the database in explorer, but the time I right click and close it, it doesn't appear in the explorer anymore.

New Query can be run properly, it's just the explorer that doesn't show up.

screen shot 2018-11-07 at 5 13 03 pm

Missing a "Create database" command

Hey there,
suppose I'm starting a new project and I need to create a new Sqlite database. A "Create database" command would be so useful, so that I don't have to download/use the Sqlite CLI just for this one-time task.

Thanks for this extension!
Moreno

intellisense

Please add intellisense for tables name in new query
Thanks

[bug?] SQLite explorer is showing some system tables?

I think your extension is still showing some system tables, as shown in the image below. AFAIK, the sqlite_sequence and sqlite_stat1 are system tables that should be hidden along with other system tables. CMIIW.

jepretan layar 2019-01-24 pukul 18 07 01

chinook.db file is taken from an SQLite tutorial site here. As shown in the article, both sqlite_sequence and sqlite_stat1 are not user-generated tables. And I can confirm that the SQLite's .tables command is not showing both tables.

Thank you.

unicode characters

Hello,
Your fix for the issue which I pointed in the review does not seem to work...
Now nothing happens when I select "show table" on a table which contains unicode text. Looks like it just fails silently somewhere... Running corresponding queries from .sql file also does not work.
For tables with English-only characters it still works.
I'm using a Mac, btw (though should not make a difference).

Incorrect syntax errors?

It seems like it's often showing syntax errors in code that is correct as far as I can tell (admittedly, I'm not very good at SQL), and works just fine.

For example, this is showing "Incorrect syntax near 'SELECT'. Expecting EDGE_TYPE, FILETABLE, or ID." for the first CREATE, and "Incorrect syntax near 'TEMP'." for the second. But the code editor in DB Browser for SQLite shows no syntax errors, and it produces the expected output with no errors in both DB Browser and the CLI.

DROP TABLE IF EXISTS temp.a;
DROP TABLE IF EXISTS temp.b; 

CREATE TEMP TABLE temp.b AS SELECT queried_at, datetime, domain, type, answers
FROM records
WHERE queried_at = ( SELECT MAX(queried_at) FROM records );

CREATE TEMP TABLE temp.a AS SELECT queried_at, datetime, domain, type, answers
FROM records
WHERE queried_at = ( 
    SELECT MAX(queried_at)
    FROM records
    WHERE queried_at NOT IN ( SELECT MAX(queried_at) FROM records ) );

SELECT a.queried_at, b.queried_at, a.domain, a.type, a.datetime, a.answers, b.datetime, b.answers FROM a INNER JOIN b ON a.domain = b.domain AND a.type = b.type WHERE a.answers <> b.answers;

[feature request] Please don't close the SQLite window on syntax error

When the user runs a query that has a syntax error, please don't close the SQLite window. Just show the error message or hint text on the appropriate position. Sometimes I align the SQLite window on a specific position, losing it forces me to re-align the window. It's annoying and a bad user experience.

Thank you.

Support the Guid datatype

Columns of type Guid are presented with the guid type
untitled
... but the columns values are not presented as Guid
image

Some tools, e.g. Database .NET are able to format the output as a GUID (instead of treating the data as UTF-8/Unicode?)
image
Can support for this be added?

Extension not being recognized by VSCode

Hello, I'm on windows 10 and have installed the extension to VSCode but now there is nothing. I'm unable to find or open the extension, and I'm still unable to open the .sqlite file. What other steps can I take? In the screenshot you can see when I try to search for sqlite, nothing appears. Do I have to direct VSCode to where it may have been installed? Where is that exactly?

image

Thanks

[feature-request] Add support for Attached database queries and project configuration

We are currently working on a project with multiple sqlite database files. Some of the queries are executed cross-database using sqlite ATTACH clause.

For this project it is necessary to be able to attach multiple databases with given names and preview them in explorer. Current version does not seem to allow to do it.

The further improvement would be the project configuration that automatically opens multiple databases with given aliases. Imagine the following configuration:

{
    "sqlite3": {
        "databases": {
            "master-only": "/database/master.db",
            "master-with-secondary": [
                { "database": "/database/master.db", "alias": "master" },
                { "database": "/database/secondary.db", "alias": "secondary" }
            ]
        }
    }
}

With such configuration user should be able to execute the following command:
SQLite: Connect to predefined

and then select master-only or master-with-secondary from the drop-down to connect. Note that the database path is relative to root directory so this configuration only makes sense in environment configuration scope.

No explorer

Hi,

I've just installed your extension for vscode 1.26.1 on Ubuntu 18.04, and reload it, but when i :

  • ctrl + maj +p
  • "open database in explorer"
  • select DB in the list

=> the explore doesn't open.

For info:

$ sqlite3 version
sqlite3 versionSQLite version 3.22.0 2018-01-22 18:45:57

$ which sqlite3
/usr/bin/sqlite3

Thx

Missing spellfix1 workaround

Some data bases are created with virtual tables please see spellfix1. Since this is not included in the official sqlite3 binaries.. the I found this workaround on stackoverflow

SQLite is an embedded database, and can be customized. The Plex Media Server has added the spellfix1 extension; the documentation says:

The spellfix1 virtual table is not included in the SQLite amalgamation and is not a part of any standard SQLite build. It is a loadable extension.

To be able to access this table, you'd have to compile this extension yourself, and load it into the Python database connection.

If you don't actually need to do spell checks, you can create a copy of the database without that virtual table:

convert the database to text with the sqlite3 command-line shell:

sqlite3 some/where/...library.db ".dump" > library.sql

(this works without the module installed);

remove the creation of the virtual table from the SQL script; it's a line looking like this:

INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)VALUES('table','xxx','xxx',0,'CREATE VIRTUAL TABLE xxx using spellfix1(...)');

create a new database from that script:

sqlite3 new.db < library.sql

Does not work on VS Code 1.26.1 for Windows

Hello

I tried to open a database but nothing happens. I assume the process is to press Ctrl/Shift/P, select SQLite: Open Database in Explorer, then enter the full path of the Sqlite database eg c:\temp\mydata.sqlite.

My VS Code details are:

  • Version: 1.26.1
  • Electron: 2.0.5
  • Chrome: 61.0.3163.100
  • Node.js: 8.9.3
  • V8: 6.1.534.41
  • Architecture: x64

Am I missing an obvious trick?!

Thanks

Save entire result page

Add the "Save Result Page" feature to save entire result page into a single html page (also remember that vscode cannot print), or copy it to clipboard.

Save all this (not only export single queries):
schermata 2018-07-20 alle 11 25 21

Fail to open DB on Windows if used Cyrillic names in the path.

Try Open DataBase in Explorer - nothing happened - no error, no messages at all.

If I try to query DB

notificationsAlerts.ts:41 Error: unable
t.onDidNotificationChange @ notificationsAlerts.ts:41
(anonymous) @ notificationsAlerts.ts:27
e.fire @ event.ts:140
t.notify @ notifications.ts:113
t.notify @ notificationService.ts:56
e._showMessage @ mainThreadMessageService.ts:84
e._showMessage @ mainThreadMessageService.ts:45
e.$showMessage @ mainThreadMessageService.ts:39
e._doInvokeHandler @ rpcProtocol.ts:322
e._invokeHandler @ rpcProtocol.ts:307
e._receiveRequest @ rpcProtocol.ts:239
e._receiveOneMessage @ rpcProtocol.ts:186
(anonymous) @ rpcProtocol.ts:115
e.fire @ event.ts:140
a @ ipc.net.ts:106
n._socketDataListener @ ipc.net.ts:135
emitOne @ events.js:116
emit @ events.js:211
addChunk @ _stream_readable.js:263
readableAddChunk @ _stream_readable.js:250
Readable.push @ _stream_readable.js:208
onread @ net.js:594
console.ts:136 [Extension Host] [9:16:34 AM][vscode-sqlite][ERROR] Error: Error: unable
t.log @ console.ts:136
t._logExtensionHostMessage @ extensionHost.ts:412
(anonymous) @ extensionHost.ts:224
emitTwo @ events.js:126
emit @ events.js:214
emit @ internal/child_process.js:772
_combinedTickCallback @ internal/process/next_tick.js:141
_tickCallback @ internal/process/next_tick.js:180

The workaround is to move DB in a folder in which path not contains Cyrillic characters.

Horizontal scrollbar should be visible

In the results pane, the horizontal scrollbar should always be visible. Currently, it only shows when I vertically scroll down far enough to see the end of the table.

freezes after "Choose another database"

When I tried to use a database by

  1. SQLite: Use Database
  2. Choose another database

vscode freezes after the file dialog opened.

I'm using vscode 1.27.2. Ubuntu 16.04. GNOME 3.18.5

Why there's no Close Database command?

Just to make sure I'm done with a database and the extension have closed it completely, I think you should provide Close database command.

Thank you.

Parsing commented query?

I receive a false error.
schermata 2018-06-28 alle 16 04 58

It's work fine from command line sqlite3 3.24.0
After some tests I found its depends from the ' --> '.

/*
SELECT name || ' --> ' || 'POST';
FROM sqlite_master 
LIMIT 1;
*/

The result is not showing on windows version 1.27.1

Just looks like this.
tim 20180908002602

But there's nothing wrong with intellij!
2345

版本: 1.27.1 (user setup)
提交: 5944e81f3c46a3938a82c701f96d7a59b074cfdc
日期: 2018-09-06T09:21:18.328Z
Electron: 2.0.7
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
架构: x64

Unable to execute sqlite3 queries, change the sqlite.sqlite3 setting to fix this issue.

Simply as title says.

  1. Installed the VSCode extension
  2. Selected command >SQLite: Open Database in Explorer
  3. Error window in bottom right with title message

image

Is this just me? I'm on Win10. Additional VSCode details below:

Version: 1.29.1 (system setup)
Commit: bc24f98b5f70467bc689abf41cc5550ca637088e
Date: 2018-11-15T19:13:36.375Z
Electron: 2.0.12
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: x64

More infos in Explorer Tree

Underline/bold a primary key field, add if it's a nullable field

Example:
Employess
id : integer (null; def="1")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.