0.4.27 • Published 10 months ago
@proj-airi/duckdb-wasm v0.4.27
Easy to use @duckdb/duckdb-wasm wrapper for both browser and Node.js environments
Installation
Pick the package manager of your choice:
ni @proj-airi/duckdb-wasm -D # from @antfu/ni, can be installed via `npm i -g @antfu/ni`
pnpm i @proj-airi/duckdb-wasm -D
yarn i @proj-airi/duckdb-wasm -D
npm i @proj-airi/duckdb-wasm -DUsage
Browser
<script setup lang="ts">
import type { DuckDBWasmClient } from '@proj-airi/duckdb-wasm'
import { connect, getEnvironment } from '@proj-airi/duckdb-wasm'
import { getImportUrlBundles } from '@proj-airi/duckdb-wasm/bundles/import-url-browser'
import { onMounted, onUnmounted, ref } from 'vue'
const db = ref<DuckDBWasmClient>()
onMounted(async () => {
db.value = await connect({ bundles: getImportUrlBundles })
const result = await db.value.conn.query('SELECT 1 + 1 AS res')
console.log(result) // Output: [{ res: 2 }]
})
onUnmounted(() => {
db.value?.close()
})
</script>Node.js
You will need to install web-worker too.
ni web-worker # from @antfu/ni, can be installed via `npm i -g @antfu/ni`
pnpm i web-worker
yarn i web-worker
npm i web-workerimport { connect, getEnvironment } from '@proj-airi/duckdb-wasm'
import { getImportUrlBundles } from '@proj-airi/duckdb-wasm/bundles/default-node'
async function main() {
const { conn, close } = await connect({ bundles: getImportUrlBundles })
const result = await conn.query('SELECT 1 + 1 AS res')
console.log(result) // Output: [{ res: 2 }]
await close()
}Footnotes
Check out the Drizzle ORM driver we made for @duckdb/duckdb-wasm as well!
0.4.27
10 months ago
0.4.25
10 months ago
0.4.26
10 months ago
0.4.24
11 months ago
0.4.23
11 months ago
0.4.22
11 months ago
0.4.21
12 months ago
0.4.20
12 months ago
0.4.19
12 months ago
0.4.18
12 months ago
0.4.17
12 months ago
0.4.16
12 months ago
0.4.15
12 months ago
0.4.14
12 months ago
0.3.6
1 year ago
0.3.4
1 year ago
0.3.3
1 year ago
0.3.2
1 year ago
0.3.1
1 year ago