-
-
Notifications
You must be signed in to change notification settings - Fork 694
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
Prototoype for Datasette on PostgreSQL #670
Comments
I'm excited about https://github.com/MagicStack/asyncpg for this - it's a true async PostgreSQL library (my SQLite queries run in a threadpool right now) with extremely impressive performance benchmarks, from the team behind |
A couple of things I'd like to support:
I can implement that with this in def pytest_addoption(parser):
parser.addoption("--database", action="store", default="sqlite") See https://stackoverflow.com/questions/40880259/how-to-pass-arguments-in-pytest-by-command-line |
The biggest difference between the two will be around introspection. I searched the codebase for potential introspection queries, defined as
|
First page to get working: the database view page, which shows a list of tables. In the code this is entirely implemented with calls to the datasette/datasette/views/database.py Lines 25 to 66 in 0091dfe
|
Introspecting columns in PostgreSQL:
Each column looks like this:
|
Finding out the primary keys for a table: https://wiki.postgresql.org/wiki/Retrieve_primary_key_columns |
|
Challenge: what's the equivalent for PostgreSQL of opening a database in read only mode? Will I have to talk users through creating read only credentials? Can I do this at runtime somehow? Can I detect if the connection has write permission and disable the arbitrary query feature? |
This prototype demonstrates the database page working against a hard-coded connection string to a PostgreSQL database. It lists tables and their columns and their row count.,
Got the database page working! It lists tables, their columns and their row count. Got the table page partially working! It can list rows. It can't apply filters yet (because PostgreSQL
Still a pretty promising start though! |
I'm currently using PostgREST to serve OpenAPI APIs off Postgresql databases. I would like to try out datasette once this becomes available on Postgres. |
It looks like the answer to this is yes - I'll need users to setup read-only credentials. Here's a TIL about that: https://til.simonwillison.net/postgresql/read-only-postgresql-user |
I've also been investigating serving postgresql databases over postgrest. I like the idea of hosting some static html + js on github, but having it backed by datasets I can update and control on the database server. I started from SQLite + datasette but would like to host larger datasets (with smaller materialized views exposed publicly). I think the postgrest model where all the authorization and ownership is defined in database role grants is really powerful. But I really miss being able to define an ad-hoc query in sql, then instantly link to a json representation of it like datasette does. P.S.: I've been sort of following along as you pop up in hacker news here and there. It's been great! Thanks for doing this all out in the open! |
Worth mentioning here: I've been doing a tun of research around running Datasette-like functionality against PostgreSQL in my https://github.com/simonw/django-sql-dashboard project - which will definitely inform the Datasette implementation. |
Is there any working version of datasette/postgresql ? |
Any progress on this? It would be very helpful on my end as well. Thanks! |
I thought this would never happen, but now that I'm deep in the weeds of running SQLite in production for Datasette Cloud I'm starting to reconsider my policy of only supporting SQLite.
Some of the factors making me think PostgreSQL support could be worth the effort:
datasette postgresql://connection-string
and start trying it out would be a massively better experience.The above reasons feel strong enough to justify a prototype.
The text was updated successfully, but these errors were encountered: