coleifer/sqlite-web

Is there an option to see views?

Closed this issue · 6 comments

I would like to see views and their data in the same way.

Not at present.

Hey Charles
Any plans on adding this feature?

I've patched a local version of this repo so that views work as intended, however the code is not up to standard so I don't feel comfortable submitting a pull request. I think there's also some work that has to be done on peewee itself for this to work perfectly.

Outline of what I did:

  • Override SqliteDataSet constructor to pass include_views=True to self._introspector.generate_models (there's no way to pass the parameter to the parent DataSet's constructor)
  • Override SqliteDataSet.update_cache for the same reason
  • Made _format_create_table aware of views and added support for CREATE VIEW <name> AS <etc> (requires more complex formatting than CREATE TABLE)
  • Adapted all SELECT sql FROM sqlite_master queries to accommodate cases WHERE type = 'view'
  • In the base_tables.html view I copied the loop that renders tables from dataset.tables and iterated over dataset.views as well

It's not perfect (some column types are not inferred, might be a peewee issue) but it answers my current needs

Official support would be nice :)

sad, would like to see this happen tbh. It is an awesome project :)

Okay so basicly there is an option, but it aint pretty. You can ez add views via queries: https://www.sqlitetutorial.net/sqlite-create-view/

And you can view them by executing queries via the Query tab in a table:
afbeelding

You can also view the list of views using:

select name, sql from sqlite_master where type = 'view' order by name