{"action":"created","comment":{"url":"https://api.github.com/repos/airbnb/caravel/pulls/comments/72838367","id":72838367,"diff_hunk":"@@ -1254,6 +1255,59 @@ def runsql(self):\n         return content\n \n     @has_access\n+    @expose(\"/sql_json/\", methods=['POST', 'GET'])\n+    @log_this\n+    def sql_json(self):\n+        \"\"\"Runs arbitrary sql and returns and json\"\"\"\n+        session = db.session()\n+        limit = 1000\n+        sql = request.form.get('sql')\n+        database_id = request.form.get('database_id')\n+        mydb = session.query(models.Database).filter_by(id=database_id).first()\n+\n+        if (\n+                not self.can_access(\n+                    'all_datasource_access', 'all_datasource_access')):\n+            raise utils.CaravelSecurityException(_(\n+                \"This view requires the `all_datasource_access` permission\"))\n+\n+        error_msg = \"\"\n+        if not mydb:\n+            error_msg = \"The database selected doesn't seem to exist\"","path":"caravel/views.py","position":30,"original_position":30,"commit_id":"ed8223e1597d8f1fa201d7a4fbbf2c8b7763f4e5","original_commit_id":"ed8223e1597d8f1fa201d7a4fbbf2c8b7763f4e5","user":{"login":"bkyryliuk","id":5727938,"avatar_url":"https://avatars.githubusercontent.com/u/5727938?v=3","gravatar_id":"","url":"https://api.github.com/users/bkyryliuk","html_url":"https://github.com/bkyryliuk","followers_url":"https://api.github.com/users/bkyryliuk/followers","following_url":"https://api.github.com/users/bkyryliuk/following{/other_user}","gists_url":"https://api.github.com/users/bkyryliuk/gists{/gist_id}","starred_url":"https://api.github.com/users/bkyryliuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkyryliuk/subscriptions","organizations_url":"https://api.github.com/users/bkyryliuk/orgs","repos_url":"https://api.github.com/users/bkyryliuk/repos","events_url":"https://api.github.com/users/bkyryliuk/events{/privacy}","received_events_url":"https://api.github.com/users/bkyryliuk/received_events","type":"User","site_admin":false},"body":"what do u think about adding database_id to the error message ?","created_at":"2016-07-29T18:22:44Z","updated_at":"2016-07-29T18:22:44Z","html_url":"https://github.com/airbnb/caravel/pull/842#discussion_r72838367","pull_request_url":"https://api.github.com/repos/airbnb/caravel/pulls/842","_links":{"self":{"href":"https://api.github.com/repos/airbnb/caravel/pulls/comments/72838367"},"html":{"href":"https://github.com/airbnb/caravel/pull/842#discussion_r72838367"},"pull_request":{"href":"https://api.github.com/repos/airbnb/caravel/pulls/842"}}},"pull_request":{"url":"https://api.github.com/repos/airbnb/caravel/pulls/842","id":79260267,"html_url":"https://github.com/airbnb/caravel/pull/842","diff_url":"https://github.com/airbnb/caravel/pull/842.diff","patch_url":"https://github.com/airbnb/caravel/pull/842.patch","issue_url":"https://api.github.com/repos/airbnb/caravel/issues/842","number":842,"state":"open","locked":false,"title":"New endpoint that receives SQL and returns data as JSON","user":{"login":"mistercrunch","id":487433,"avatar_url":"https://avatars.githubusercontent.com/u/487433?v=3","gravatar_id":"","url":"https://api.github.com/users/mistercrunch","html_url":"https://github.com/mistercrunch","followers_url":"https://api.github.com/users/mistercrunch/followers","following_url":"https://api.github.com/users/mistercrunch/following{/other_user}","gists_url":"https://api.github.com/users/mistercrunch/gists{/gist_id}","starred_url":"https://api.github.com/users/mistercrunch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mistercrunch/subscriptions","organizations_url":"https://api.github.com/users/mistercrunch/orgs","repos_url":"https://api.github.com/users/mistercrunch/repos","events_url":"https://api.github.com/users/mistercrunch/events{/privacy}","received_events_url":"https://api.github.com/users/mistercrunch/received_events","type":"User","site_admin":false},"body":"@bkyryliuk ","created_at":"2016-07-28T20:12:48Z","updated_at":"2016-07-29T18:22:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"17aaaf3ffddaddbef9ad17cfedcf8444f6a291ed","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/airbnb/caravel/pulls/842/commits","review_comments_url":"https://api.github.com/repos/airbnb/caravel/pulls/842/comments","review_comment_url":"https://api.github.com/repos/airbnb/caravel/pulls/comments{/number}","comments_url":"https://api.github.com/repos/airbnb/caravel/issues/842/comments","statuses_url":"https://api.github.com/repos/airbnb/caravel/statuses/ed8223e1597d8f1fa201d7a4fbbf2c8b7763f4e5","head":{"label":"mistercrunch:sql_json","ref":"sql_json","sha":"ed8223e1597d8f1fa201d7a4fbbf2c8b7763f4e5","user":{"login":"mistercrunch","id":487433,"avatar_url":"https://avatars.githubusercontent.com/u/487433?v=3","gravatar_id":"","url":"https://api.github.com/users/mistercrunch","html_url":"https://github.com/mistercrunch","followers_url":"https://api.github.com/users/mistercrunch/followers","following_url":"https://api.github.com/users/mistercrunch/following{/other_user}","gists_url":"https://api.github.com/users/mistercrunch/gists{/gist_id}","starred_url":"https://api.github.com/users/mistercrunch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mistercrunch/subscriptions","organizations_url":"https://api.github.com/users/mistercrunch/orgs","repos_url":"https://api.github.com/users/mistercrunch/repos","events_url":"https://api.github.com/users/mistercrunch/events{/privacy}","received_events_url":"https://api.github.com/users/mistercrunch/received_events","type":"User","site_admin":false},"repo":{"id":56703070,"name":"caravel","full_name":"mistercrunch/caravel","owner":{"login":"mistercrunch","id":487433,"avatar_url":"https://avatars.githubusercontent.com/u/487433?v=3","gravatar_id":"","url":"https://api.github.com/users/mistercrunch","html_url":"https://github.com/mistercrunch","followers_url":"https://api.github.com/users/mistercrunch/followers","following_url":"https://api.github.com/users/mistercrunch/following{/other_user}","gists_url":"https://api.github.com/users/mistercrunch/gists{/gist_id}","starred_url":"https://api.github.com/users/mistercrunch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mistercrunch/subscriptions","organizations_url":"https://api.github.com/users/mistercrunch/orgs","repos_url":"https://api.github.com/users/mistercrunch/repos","events_url":"https://api.github.com/users/mistercrunch/events{/privacy}","received_events_url":"https://api.github.com/users/mistercrunch/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mistercrunch/caravel","description":"Caravel is a data exploration platform designed to be visual, intuitive, and interactive","fork":true,"url":"https://api.github.com/repos/mistercrunch/caravel","forks_url":"https://api.github.com/repos/mistercrunch/caravel/forks","keys_url":"https://api.github.com/repos/mistercrunch/caravel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mistercrunch/caravel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mistercrunch/caravel/teams","hooks_url":"https://api.github.com/repos/mistercrunch/caravel/hooks","issue_events_url":"https://api.github.com/repos/mistercrunch/caravel/issues/events{/number}","events_url":"https://api.github.com/repos/mistercrunch/caravel/events","assignees_url":"https://api.github.com/repos/mistercrunch/caravel/assignees{/user}","branches_url":"https://api.github.com/repos/mistercrunch/caravel/branches{/branch}","tags_url":"https://api.github.com/repos/mistercrunch/caravel/tags","blobs_url":"https://api.github.com/repos/mistercrunch/caravel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mistercrunch/caravel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mistercrunch/caravel/git/refs{/sha}","trees_url":"https://api.github.com/repos/mistercrunch/caravel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mistercrunch/caravel/statuses/{sha}","languages_url":"https://api.github.com/repos/mistercrunch/caravel/languages","stargazers_url":"https://api.github.com/repos/mistercrunch/caravel/stargazers","contributors_url":"https://api.github.com/repos/mistercrunch/caravel/contributors","subscribers_url":"https://api.github.com/repos/mistercrunch/caravel/subscribers","subscription_url":"https://api.github.com/repos/mistercrunch/caravel/subscription","commits_url":"https://api.github.com/repos/mistercrunch/caravel/commits{/sha}","git_commits_url":"https://api.github.com/repos/mistercrunch/caravel/git/commits{/sha}","comments_url":"https://api.github.com/repos/mistercrunch/caravel/comments{/number}","issue_comment_url":"https://api.github.com/repos/mistercrunch/caravel/issues/comments{/number}","contents_url":"https://api.github.com/repos/mistercrunch/caravel/contents/{+path}","compare_url":"https://api.github.com/repos/mistercrunch/caravel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mistercrunch/caravel/merges","archive_url":"https://api.github.com/repos/mistercrunch/caravel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mistercrunch/caravel/downloads","issues_url":"https://api.github.com/repos/mistercrunch/caravel/issues{/number}","pulls_url":"https://api.github.com/repos/mistercrunch/caravel/pulls{/number}","milestones_url":"https://api.github.com/repos/mistercrunch/caravel/milestones{/number}","notifications_url":"https://api.github.com/repos/mistercrunch/caravel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mistercrunch/caravel/labels{/name}","releases_url":"https://api.github.com/repos/mistercrunch/caravel/releases{/id}","deployments_url":"https://api.github.com/repos/mistercrunch/caravel/deployments","created_at":"2016-04-20T16:28:49Z","updated_at":"2016-04-20T16:28:50Z","pushed_at":"2016-07-28T20:12:38Z","git_url":"git://github.com/mistercrunch/caravel.git","ssh_url":"git@github.com:mistercrunch/caravel.git","clone_url":"https://github.com/mistercrunch/caravel.git","svn_url":"https://github.com/mistercrunch/caravel","homepage":"","size":36679,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"airbnb:master","ref":"master","sha":"299e31fdff1861c434c18efaed804d63572aec16","user":{"login":"airbnb","id":698437,"avatar_url":"https://avatars.githubusercontent.com/u/698437?v=3","gravatar_id":"","url":"https://api.github.com/users/airbnb","html_url":"https://github.com/airbnb","followers_url":"https://api.github.com/users/airbnb/followers","following_url":"https://api.github.com/users/airbnb/following{/other_user}","gists_url":"https://api.github.com/users/airbnb/gists{/gist_id}","starred_url":"https://api.github.com/users/airbnb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/airbnb/subscriptions","organizations_url":"https://api.github.com/users/airbnb/orgs","repos_url":"https://api.github.com/users/airbnb/repos","events_url":"https://api.github.com/users/airbnb/events{/privacy}","received_events_url":"https://api.github.com/users/airbnb/received_events","type":"Organization","site_admin":false},"repo":{"id":39464018,"name":"caravel","full_name":"airbnb/caravel","owner":{"login":"airbnb","id":698437,"avatar_url":"https://avatars.githubusercontent.com/u/698437?v=3","gravatar_id":"","url":"https://api.github.com/users/airbnb","html_url":"https://github.com/airbnb","followers_url":"https://api.github.com/users/airbnb/followers","following_url":"https://api.github.com/users/airbnb/following{/other_user}","gists_url":"https://api.github.com/users/airbnb/gists{/gist_id}","starred_url":"https://api.github.com/users/airbnb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/airbnb/subscriptions","organizations_url":"https://api.github.com/users/airbnb/orgs","repos_url":"https://api.github.com/users/airbnb/repos","events_url":"https://api.github.com/users/airbnb/events{/privacy}","received_events_url":"https://api.github.com/users/airbnb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/airbnb/caravel","description":"Caravel is a data exploration platform designed to be visual, intuitive, and interactive","fork":false,"url":"https://api.github.com/repos/airbnb/caravel","forks_url":"https://api.github.com/repos/airbnb/caravel/forks","keys_url":"https://api.github.com/repos/airbnb/caravel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/airbnb/caravel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/airbnb/caravel/teams","hooks_url":"https://api.github.com/repos/airbnb/caravel/hooks","issue_events_url":"https://api.github.com/repos/airbnb/caravel/issues/events{/number}","events_url":"https://api.github.com/repos/airbnb/caravel/events","assignees_url":"https://api.github.com/repos/airbnb/caravel/assignees{/user}","branches_url":"https://api.github.com/repos/airbnb/caravel/branches{/branch}","tags_url":"https://api.github.com/repos/airbnb/caravel/tags","blobs_url":"https://api.github.com/repos/airbnb/caravel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/airbnb/caravel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/airbnb/caravel/git/refs{/sha}","trees_url":"https://api.github.com/repos/airbnb/caravel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/airbnb/caravel/statuses/{sha}","languages_url":"https://api.github.com/repos/airbnb/caravel/languages","stargazers_url":"https://api.github.com/repos/airbnb/caravel/stargazers","contributors_url":"https://api.github.com/repos/airbnb/caravel/contributors","subscribers_url":"https://api.github.com/repos/airbnb/caravel/subscribers","subscription_url":"https://api.github.com/repos/airbnb/caravel/subscription","commits_url":"https://api.github.com/repos/airbnb/caravel/commits{/sha}","git_commits_url":"https://api.github.com/repos/airbnb/caravel/git/commits{/sha}","comments_url":"https://api.github.com/repos/airbnb/caravel/comments{/number}","issue_comment_url":"https://api.github.com/repos/airbnb/caravel/issues/comments{/number}","contents_url":"https://api.github.com/repos/airbnb/caravel/contents/{+path}","compare_url":"https://api.github.com/repos/airbnb/caravel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/airbnb/caravel/merges","archive_url":"https://api.github.com/repos/airbnb/caravel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/airbnb/caravel/downloads","issues_url":"https://api.github.com/repos/airbnb/caravel/issues{/number}","pulls_url":"https://api.github.com/repos/airbnb/caravel/pulls{/number}","milestones_url":"https://api.github.com/repos/airbnb/caravel/milestones{/number}","notifications_url":"https://api.github.com/repos/airbnb/caravel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/airbnb/caravel/labels{/name}","releases_url":"https://api.github.com/repos/airbnb/caravel/releases{/id}","deployments_url":"https://api.github.com/repos/airbnb/caravel/deployments","created_at":"2015-07-21T18:55:34Z","updated_at":"2016-07-29T17:19:57Z","pushed_at":"2016-07-29T18:10:45Z","git_url":"git://github.com/airbnb/caravel.git","ssh_url":"git@github.com:airbnb/caravel.git","clone_url":"https://github.com/airbnb/caravel.git","svn_url":"https://github.com/airbnb/caravel","homepage":"","size":39204,"stargazers_count":6809,"watchers_count":6809,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":715,"mirror_url":null,"open_issues_count":195,"forks":715,"open_issues":195,"watchers":6809,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/airbnb/caravel/pulls/842"},"html":{"href":"https://github.com/airbnb/caravel/pull/842"},"issue":{"href":"https://api.github.com/repos/airbnb/caravel/issues/842"},"comments":{"href":"https://api.github.com/repos/airbnb/caravel/issues/842/comments"},"review_comments":{"href":"https://api.github.com/repos/airbnb/caravel/pulls/842/comments"},"review_comment":{"href":"https://api.github.com/repos/airbnb/caravel/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/airbnb/caravel/pulls/842/commits"},"statuses":{"href":"https://api.github.com/repos/airbnb/caravel/statuses/ed8223e1597d8f1fa201d7a4fbbf2c8b7763f4e5"}}}}
{"actor":{"display_login":"bkyryliuk"}}