-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for dynamic extensions #1
Comments
Alternatively, allow switches in the magoc that creates the initial pglite instance and connection to install one or more extensions. Also have a magic that lists the available extensions. |
I've made a start on supporting extensions. Check availability as: from jupyter_anywidget_pglite import AVAILABLE_EXTENSIONS
AVAILABLE_EXTENSIONS
>>>['fuzzystrmatch', 'pg_trgm', 'vector'] Then load via the from jupyter_anywidget_pglite import pglite_panel
# Launch it
pg_panel = pglite_panel(extensions=["vector", "fuzzystrmatch", "pg_trgm"]) The required packaes are loaded dynamically: async function loadExtensions(extensions) {
const extensionsObj = {};
const extensionModules = [
{
name: "fuzzystrmatch",
url: "https://cdn.jsdelivr.net/npm/@electric-sql/pglite/dist/contrib/fuzzystrmatch.js",
},
{
name: "pg_trgm",
url: "https://cdn.jsdelivr.net/npm/@electric-sql/pglite/dist/contrib/pg_trgm.js",
},
{
name: "vector",
url: "https://cdn.jsdelivr.net/npm/@electric-sql/pglite/dist/vector/index.js",
},
];
// Prepare an array of promises for the imports
const importPromises = extensionModules.map(async ({ name, url }) => {
if (extensions.includes(name)) {
try {
const module = await import(url);
extensionsObj[name] = module[name];
} catch (error) {
handle_error(error);
console.error(`Failed to load ${name}:`, error);
}
}
});
// Wait for all import promises to complete
await Promise.all(importPromises);
return extensionsObj;
} So this approach should allow for us passing in additional, arbitrary extensions, e.g. via a |
See https://lantern.dev/blog/pglite-lantern for examples of a fork that supports loading postgres extensions.
The text was updated successfully, but these errors were encountered: