Skip to content

Commit 1d569ef

Browse files
authored
Update README.md
1 parent eb7340c commit 1d569ef

File tree

1 file changed

+31
-75
lines changed

1 file changed

+31
-75
lines changed

README.md

Lines changed: 31 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,42 @@
1-
# Webxtension
1+
# DuckDB Webxtension
22

3-
This repository is based on https://github.com/duckdb/extension-template, check it out if you want to build and ship your own DuckDB extension.
3+
This extension allows loading DuckDB Macros (both scalar and table) from URLs, gists, pasties, etc.
44

5-
---
5+
### Installation
66

7-
This extension, Webxtension, allow you to ... <extension_goal>.
7+
> Coming Soon
88
9+
### Usage
10+
Create a DuckDB SQL Macro and save it somewhere. Here's an [example](https://gist.github.com/lmangani/518215a68e674ac662537d518799b893)
911

10-
## Building
11-
### Managing dependencies
12-
DuckDB extensions uses VCPKG for dependency management. Enabling VCPKG is very simple: follow the [installation instructions](https://vcpkg.io/en/getting-started) or just run the following:
13-
```shell
14-
git clone https://github.com/Microsoft/vcpkg.git
15-
./vcpkg/bootstrap-vcpkg.sh
16-
export VCPKG_TOOLCHAIN_PATH=`pwd`/vcpkg/scripts/buildsystems/vcpkg.cmake
17-
```
18-
Note: VCPKG is only required for extensions that want to rely on it for dependency management. If you want to develop an extension without dependencies, or want to do your own dependency management, just skip this step. Note that the example extension uses VCPKG to build with a dependency for instructive purposes, so when skipping this step the build may not work without removing the dependency.
19-
20-
### Build steps
21-
Now to build the extension, run:
22-
```sh
23-
make
24-
```
25-
The main binaries that will be built are:
26-
```sh
27-
./build/release/duckdb
28-
./build/release/test/unittest
29-
./build/release/extension/webxtension/webxtension.duckdb_extension
30-
```
31-
- `duckdb` is the binary for the duckdb shell with the extension code automatically loaded.
32-
- `unittest` is the test runner of duckdb. Again, the extension is already linked into the binary.
33-
- `webxtension.duckdb_extension` is the loadable binary as it would be distributed.
34-
35-
## Running the extension
36-
To run the extension code, simply start the shell with `./build/release/duckdb`.
37-
38-
Now we can use the features from the extension directly in DuckDB. The template contains a single scalar function `webxtension()` that takes a string arguments and returns a string:
39-
```
40-
D select webxtension('Jane') as result;
41-
┌───────────────┐
42-
│ result │
43-
│ varchar │
44-
├───────────────┤
45-
│ Webxtension Jane 🐥 │
46-
└───────────────┘
47-
```
48-
49-
## Running the tests
50-
Different tests can be created for DuckDB extensions. The primary way of testing DuckDB extensions should be the SQL tests in `./test/sql`. These SQL tests can be run using:
51-
```sh
52-
make test
53-
```
54-
55-
### Installing the deployed binaries
56-
To install your extension binaries from S3, you will need to do two things. Firstly, DuckDB should be launched with the
57-
`allow_unsigned_extensions` option set to true. How to set this will depend on the client you're using. Some examples:
12+
Load your remote macro onto your system using a URL:
5813

59-
CLI:
60-
```shell
61-
duckdb -unsigned
62-
```
63-
64-
Python:
65-
```python
66-
con = duckdb.connect(':memory:', config={'allow_unsigned_extensions' : 'true'})
67-
```
68-
69-
NodeJS:
70-
```js
71-
db = new duckdb.Database(':memory:', {"allow_unsigned_extensions": "true"});
72-
```
73-
74-
Secondly, you will need to set the repository endpoint in DuckDB to the HTTP url of your bucket + version of the extension
75-
you want to install. To do this run the following SQL query in DuckDB:
7614
```sql
77-
SET custom_extension_repository='bucket.s3.eu-west-1.amazonaws.com/<your_extension_name>/latest';
15+
D SELECT load_macro_from_url('https://gist.github.com/lmangani/518215a68e674ac662537d518799b893/raw/5f305480fdd7468f4ecda3686011bab8e8e711bf/bsky.sql');
16+
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
17+
│ load_macro_from_url('https://gist.github.com/lmangani/518215a68e674ac662537d518799b893/raw/5f305480fdd7468f4ecda36… │
18+
│ varchar │
19+
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
20+
│ Successfully loaded macro │
21+
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
7822
```
79-
Note that the `/latest` path will allow you to install the latest extension version available for your current version of
80-
DuckDB. To specify a specific version, you can pass the version instead.
8123
82-
After running these steps, you can install and load your extension using the regular INSTALL/LOAD commands in DuckDB:
24+
Use your new macro and have fun:
25+
8326
```sql
84-
INSTALL webxtension
85-
LOAD webxtension
27+
D SELECT * FROM search_posts('qxip.bsky.social', text := 'quack');
28+
┌──────────────────┬──────────────┬──────────────────────┬───┬─────────┬─────────┬───────┬────────┐
29+
│ author_handle │ display_name │ post_text │ … │ replies │ reposts │ likes │ quotes │
30+
│ varchar │ varchar │ varchar │ │ int64 │ int64 │ int64 │ int64 │
31+
├──────────────────┼──────────────┼──────────────────────┼───┼─────────┼─────────┼───────┼────────┤
32+
│ qxip.bsky.social │ qxip │ This is super cool… │ … │ 1 │ 0 │ 1 │ 0 │
33+
│ qxip.bsky.social │ qxip │ github.com/quacksc… │ … │ 0 │ 1 │ 2 │ 0 │
34+
│ qxip.bsky.social │ qxip │ #DuckDB works grea… │ … │ 2 │ 3 │ 24 │ 0 │
35+
│ qxip.bsky.social │ qxip │ github.com/quacksc… │ … │ 1 │ 0 │ 0 │ 0 │
36+
│ qxip.bsky.social │ qxip │ The latest #Quackp… │ … │ 0 │ 0 │ 2 │ 0 │
37+
│ qxip.bsky.social │ qxip │ The #DuckDB Ecosys… │ … │ 0 │ 0 │ 5 │ 0 │
38+
│ qxip.bsky.social │ qxip │ Ladies and Gents, … │ … │ 1 │ 0 │ 4 │ 0 │
39+
├──────────────────┴──────────────┴──────────────────────┴───┴─────────┴─────────┴───────┴────────┤
40+
│ 7 rows 9 columns (7 shown) │
41+
└─────────────────────────────────────────────────────────────────────────────────────────────────┘
8642
```

0 commit comments

Comments
 (0)