innovationOUtside / jupyter_anywidget_pglite

Jupyter anywidget and magic for working with pglite (single use postgres wasm build)
MIT License
0 stars 0 forks source link

Improved handling of multi-statement queries #14

Closed psychemedia closed 3 months ago

psychemedia commented 3 months ago

We can handle multlupe query statements with the .exec() call https://github.com/electric-sql/pglite/blob/main/docs/docs/api.md#exec

await pg.exec(`
  CREATE TABLE IF NOT EXISTS test (
    id SERIAL PRIMARY KEY,
    name TEXT
  );
  INSERT INTO test (name) VALUES ('test');
  SELECT * FROM test;
`)
[
   { affectedRows: 0 },
   { affectedRows: 1 },
   {
     rows: [
       { id: 1, name: 'test' }
     ]
    affectedRows: 0,
     fields: [
       { name: 'id', dataTypeID: '23' },
       { name: 'name', dataTypeID: '25' },
    ]
   }
]