-
Notifications
You must be signed in to change notification settings - Fork 0
/
installing-duckdb.qmd
63 lines (37 loc) · 2 KB
/
installing-duckdb.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
title: "Installing duckDB"
---
## Installation
DuckDB has been installed on the MEDS server. We also recommend to install it on your personal machine following those instructions: <https://duckdb.org/docs/installation/>
## Visual code integration (optional)
You can use DuckDB directly from the terminal but if you also want to have the option to have both a SQL script and the terminal open, we recommend to use visual code. There is one setting to be done to link the script and the terminal:
In Visual Code:
- open the palette <kbd>Shift</kbd>+<kbd>Cmd</kbd>+<kbd>P</kbd> and search for: `Preferences: Open Keyboard Shortcuts (JSON)` ![](img/duckdb-vscode_setup.png)
- enter the following text & save
```json
// Place your key bindings in this file to override the defaults
[
{
"key": "shift+enter",
"command": "workbench.action.terminal.runSelectedText"
}
]
```
OR alternative method to set this up:
Under the main VS menu, go to _Settings_ -> Keyboard Shortcuts, search for "run selected", the "run selected text in active terminal" will be one of the options. Set the shift-enter keypress by double-clicking. Right-click on the _When_ column, select _Change When Expression_, and add `editorLangId == 'sql'` to restrict to just SQL files and not every kind of file.
*Now you can hit <kbd>Shift</kbd>+<kbd>Return</kbd> at then end of a line in your SQL script and it should run the command directly in the terminal!*
## Test
Let's test our new installation using visual code
1. open a terminal from the _terminal_ menu -> _new terminal_
2. In the terminal type `duckdb`, this should start duckdb
3. Open a New text file: _file_ menu -> _new text file_
4. Copy paste the following code:
```sql
-- Start the DB at the terminal: duckdb
CREATE TABLE ducks AS SELECT 3 As age, 'mandarin' AS breed;
SHOW TABLES;
FROM ducks SELECT *;
```
5. Use <kbd>Shift</kbd>+<kbd>Return</kbd> to run the SQL code line by line
You should have something that looks like this:
![](img/duckdb-vscode_test.png)