Start of PostgreSQL prototype, refs #670

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.,
This commit is contained in:
Simon Willison 2020-02-13 12:15:37 -08:00
commit 32a2f5793a
2 changed files with 206 additions and 1 deletions

View file

@ -2,6 +2,7 @@ import os
from datasette.utils import to_css_class, validate_sql_select
from datasette.utils.asgi import AsgiFileDownload
from datasette.postgresql_database import PostgresqlDatabase
from .base import DatasetteError, DataView
@ -22,7 +23,12 @@ class DatabaseView(DataView):
request, database, hash, sql, _size=_size, metadata=metadata
)
db = self.ds.databases[database]
# db = self.ds.databases[database]
db = PostgresqlDatabase(
self.ds,
"simonwillisonblog",
"postgresql://postgres@localhost/simonwillisonblog",
)
table_counts = await db.table_counts(5)
views = await db.view_names()