| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c0175a9 commit 53f9a90
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -296,7 +296,7 @@ added: v22.5.0 | |||
| 296 | 296 | Closes the database connection. An exception is thrown if the database is not | |
| 297 | 297 | open. This method is a wrapper around [`sqlite3_close_v2()`][]. | |
| 298 | 298 | ||
| 299 | - ### `database.loadExtension(path)` | ||
| 299 | + ### `database.loadExtension(path[, entryPoint])` | ||
| 300 | 300 | ||
| 301 | 301 | <!-- YAML | |
| 302 | 302 | added: | |
@@ -305,11 +305,37 @@ added: | |||
| 305 | 305 | --> | |
| 306 | 306 | ||
| 307 | 307 | * `path` {string} The path to the shared library to load. | |
| 308 | + * `entryPoint` {string} The name of the extension's entry-point function. When | ||
| 309 | + omitted, SQLite derives the entry point from the shared library's filename; | ||
| 310 | + pass this argument explicitly when the derived name does not match. | ||
| 308 | 311 | ||
| 309 | 312 | Loads a shared library into the database connection. This method is a wrapper | |
| 310 | 313 | around [`sqlite3_load_extension()`][]. It is required to enable the | |
| 311 | 314 | `allowExtension` option when constructing the `DatabaseSync` instance. | |
| 312 | 315 | ||
| 316 | + ```mjs | ||
| 317 | + import { DatabaseSync } from 'node:sqlite'; | ||
| 318 | + const database = new DatabaseSync(':memory:', { allowExtension: true }); | ||
| 319 | + | ||
| 320 | + // Load using the entry point derived from the filename. | ||
| 321 | + database.loadExtension('./decimal.dylib'); | ||
| 322 | + | ||
| 323 | + // Override the entry point when the derived name does not match. | ||
| 324 | + database.loadExtension('./base64.dylib', 'sqlite3_base64_init'); | ||
| 325 | + ``` | ||
| 326 | + | ||
| 327 | + ```cjs | ||
| 328 | + 'use strict'; | ||
| 329 | + const { DatabaseSync } = require('node:sqlite'); | ||
| 330 | + const database = new DatabaseSync(':memory:', { allowExtension: true }); | ||
| 331 | + | ||
| 332 | + // Load using the entry point derived from the filename. | ||
| 333 | + database.loadExtension('./decimal.dylib'); | ||
| 334 | + | ||
| 335 | + // Override the entry point when the derived name does not match. | ||
| 336 | + database.loadExtension('./base64.dylib', 'sqlite3_base64_init'); | ||
| 337 | + ``` | ||
| 338 | + | ||
| 313 | 339 | ### `database.enableLoadExtension(allow)` | |
| 314 | 340 | ||
| 315 | 341 | <!-- YAML | |
| Back | FazBrowse Home | New Git URL |
0 commit comments