Allow ?sql= argument against database

e.g. /database-234324?sql=select * from table limit 1
This commit is contained in:
Simon Willison 2017-10-23 19:48:56 -07:00
commit 0fa1772697

3
app.py
View file

@ -137,7 +137,8 @@ class DatabaseView(BaseView):
def data(self, request, name, hash):
conn = get_conn(name)
rows = conn.execute('select * from sqlite_master')
sql = request.args.get('sql') or 'select * from sqlite_master'
rows = conn.execute(sql)
columns = [r[0] for r in rows.description]
return {
'database': name,