0.4.27 • Published 6 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
6 months ago
0.4.25
6 months ago
0.4.26
6 months ago
0.4.24
7 months ago
0.4.23
7 months ago
0.4.22
7 months ago
0.4.21
8 months ago
0.4.20
8 months ago
0.4.19
8 months ago
0.4.18
8 months ago
0.4.17
8 months ago
0.4.16
8 months ago
0.4.15
8 months ago
0.4.14
8 months ago
0.3.6
9 months ago
0.3.4
9 months ago
0.3.3
9 months ago
0.3.2
9 months ago
0.3.1
9 months ago