Skip to content
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

prepare_connection() plugin hook #574

Closed
simonw opened this issue Jul 22, 2023 · 3 comments · Fixed by #573
Closed

prepare_connection() plugin hook #574

simonw opened this issue Jul 22, 2023 · 3 comments · Fixed by #573
Labels
enhancement New feature or request plugins

Comments

@simonw
Copy link
Owner

simonw commented Jul 22, 2023

Splitting off an issue for prepare_connection() since Alex got the PR in seconds before I shipped 3.34!

Originally posted by @simonw in #567 (comment)

@simonw
Copy link
Owner Author

simonw commented Jul 22, 2023

Alex built this in:

@simonw simonw added plugins enhancement New feature or request labels Jul 22, 2023
@simonw simonw linked a pull request Jul 22, 2023 that will close this issue
simonw added a commit that referenced this issue Jul 22, 2023
Closes:
- #574

Refs #567

---------

Co-authored-by: Simon Willison <swillison@gmail.com>
@simonw
Copy link
Owner Author

simonw commented Jul 22, 2023

@simonw
Copy link
Owner Author

simonw commented Jul 22, 2023

Just tried this out by adding the example from the docs to my sqlite-utils-hello-world plugin and running:

sqlite-utils install -e ../sqlite-utils-hello-world 
Obtaining file:///Users/simon/Dropbox/Development/sqlite-utils-hello-world
...

Then:

sqlite-utils memory "select hello('simon')"
[{"hello('simon')": "Hello, simon!"}]

Also:

>>> import sqlite_utils
>>> db = sqlite_utils.Database(memory=True)
>>> list(db.query("select hello('simon')"))
[{"hello('simon')": 'Hello, simon!'}]
>>> db2 = sqlite_utils.Database(memory=True, execute_plugins=False)
>>> list(db2.query("select hello('simon')"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/simon/Dropbox/Development/sqlite-utils/sqlite_utils/db.py", line 494, in query
    cursor = self.execute(sql, params or tuple())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/Dropbox/Development/sqlite-utils/sqlite_utils/db.py", line 512, in execute
    return self.conn.execute(sql, parameters)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlean.dbapi2.OperationalError: no such function: hello

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant