{"action":"created","comment":{"url":"https://api.github.com/repos/getredash/redash/pulls/comments/74920074","id":74920074,"diff_hunk":"@@ -0,0 +1,137 @@\n+import json\n+import sys\n+import logging\n+\n+from redash.query_runner import *\n+from redash.utils import JSONEncoder\n+\n+logger = logging.getLogger(__name__)\n+\n+class Cassandra(BaseQueryRunner):\n+    @classmethod\n+    def configuration_schema(cls):\n+        return {\n+            'type': 'object',\n+            'properties': {\n+                'host': {\n+                    'type': 'string',\n+                },\n+                'port': {\n+                    'type': 'number',\n+                    'default': 9042,\n+                },\n+                'Keyspace': {\n+                    'type': 'string',\n+                    'title': 'Keyspace name'\n+                },\n+                'username': {\n+                    'type': 'string',\n+                    'title': 'Username'\n+                },\n+                'password': {\n+                    'type': 'string',\n+                    'title': 'Password'\n+                }\n+            },\n+            'required': ['Keyspace']\n+        }\n+\n+    @classmethod\n+    def type(cls):\n+        return \"Cassandra\"\n+\n+    @classmethod\n+    def enabled(cls):\n+        try:\n+            from cassandra.cluster import Cluster\n+        except ImportError:\n+            return False\n+\n+        return True\n+\n+    def _get_tables(self, schema):\n+        query = \"\"\"\n+        select columnfamily_name from system.schema_columnfamilies where keyspace_name = '{}';\n+        \"\"\".format(self.configuration['Keyspace'])\n+\n+        results = self.run_query(query)\n+        return results, error\n+\n+    def run_query(self, query):\n+        from cassandra.cluster import Cluster\n+        connection = None\n+        try:\n+            if self.configuration.get('username', '') and self.configuration.get('password', ''):\n+                auth_provider = PlainTextAuthProvider(username='{}'.format(self.configuration.get('username', '')),\n+                                                      password='{}'.format(self.configuration.get('password', '')))\n+                connection = Cluster([self.configuration.get('host', '')], auth_provider=auth_provider)\n+            else:\n+                connection = Cluster([self.configuration.get('host', '')])\n+\n+            session = connection.connect()\n+            logger.info(\"Cassandra running query: %s\", query)\n+            result = session.execute(query)\n+\n+            column_names = []\n+            columns = []\n+            for i in result.column_names:\n+                column_names.append(i)\n+\n+            for column_name in column_names:\n+\n+                columns.append({\n+                    'name': column_name,\n+                    'friendly_name': column_name,\n+                    'type': 'string'\n+                })\n+            rows = [dict(zip(column_names, row)) for row in result]\n+\n+            data = {'columns': columns, 'rows': rows}\n+            json_data = json.dumps(data, cls=JSONEncoder)\n+\n+            error = None\n+\n+        except cassandra.cluster.Error, e:\n+            error = e.args[1]\n+        except KeyboardInterrupt:\n+            error = \"Query cancelled by user.\"\n+        except Exception as e:\n+            raise sys.exc_info()[1], None, sys.exc_info()[2]","path":"redash/query_runner/cass.py","position":99,"original_position":99,"commit_id":"87d77d4d27e7c986b922d3be68b04ec99ea8a1e6","original_commit_id":"87d77d4d27e7c986b922d3be68b04ec99ea8a1e6","user":{"login":"arikfr","id":71468,"avatar_url":"https://avatars.githubusercontent.com/u/71468?v=3","gravatar_id":"","url":"https://api.github.com/users/arikfr","html_url":"https://github.com/arikfr","followers_url":"https://api.github.com/users/arikfr/followers","following_url":"https://api.github.com/users/arikfr/following{/other_user}","gists_url":"https://api.github.com/users/arikfr/gists{/gist_id}","starred_url":"https://api.github.com/users/arikfr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arikfr/subscriptions","organizations_url":"https://api.github.com/users/arikfr/orgs","repos_url":"https://api.github.com/users/arikfr/repos","events_url":"https://api.github.com/users/arikfr/events{/privacy}","received_events_url":"https://api.github.com/users/arikfr/received_events","type":"User","site_admin":false},"body":"This is not necessary.","created_at":"2016-08-16T11:54:20Z","updated_at":"2016-08-16T11:54:20Z","html_url":"https://github.com/getredash/redash/pull/1236#discussion_r74920074","pull_request_url":"https://api.github.com/repos/getredash/redash/pulls/1236","_links":{"self":{"href":"https://api.github.com/repos/getredash/redash/pulls/comments/74920074"},"html":{"href":"https://github.com/getredash/redash/pull/1236#discussion_r74920074"},"pull_request":{"href":"https://api.github.com/repos/getredash/redash/pulls/1236"}}},"pull_request":{"url":"https://api.github.com/repos/getredash/redash/pulls/1236","id":81453687,"html_url":"https://github.com/getredash/redash/pull/1236","diff_url":"https://github.com/getredash/redash/pull/1236.diff","patch_url":"https://github.com/getredash/redash/pull/1236.patch","issue_url":"https://api.github.com/repos/getredash/redash/issues/1236","number":1236,"state":"open","locked":false,"title":"Added new DS for Cassandra and ScyllaDB","user":{"login":"yershalom","id":7933604,"avatar_url":"https://avatars.githubusercontent.com/u/7933604?v=3","gravatar_id":"","url":"https://api.github.com/users/yershalom","html_url":"https://github.com/yershalom","followers_url":"https://api.github.com/users/yershalom/followers","following_url":"https://api.github.com/users/yershalom/following{/other_user}","gists_url":"https://api.github.com/users/yershalom/gists{/gist_id}","starred_url":"https://api.github.com/users/yershalom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yershalom/subscriptions","organizations_url":"https://api.github.com/users/yershalom/orgs","repos_url":"https://api.github.com/users/yershalom/repos","events_url":"https://api.github.com/users/yershalom/events{/privacy}","received_events_url":"https://api.github.com/users/yershalom/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-16T11:11:42Z","updated_at":"2016-08-16T11:54:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ede2053673baa007cd57c0fa4c225e2aefc2609e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/getredash/redash/pulls/1236/commits","review_comments_url":"https://api.github.com/repos/getredash/redash/pulls/1236/comments","review_comment_url":"https://api.github.com/repos/getredash/redash/pulls/comments{/number}","comments_url":"https://api.github.com/repos/getredash/redash/issues/1236/comments","statuses_url":"https://api.github.com/repos/getredash/redash/statuses/87d77d4d27e7c986b922d3be68b04ec99ea8a1e6","head":{"label":"yershalom:master","ref":"master","sha":"87d77d4d27e7c986b922d3be68b04ec99ea8a1e6","user":{"login":"yershalom","id":7933604,"avatar_url":"https://avatars.githubusercontent.com/u/7933604?v=3","gravatar_id":"","url":"https://api.github.com/users/yershalom","html_url":"https://github.com/yershalom","followers_url":"https://api.github.com/users/yershalom/followers","following_url":"https://api.github.com/users/yershalom/following{/other_user}","gists_url":"https://api.github.com/users/yershalom/gists{/gist_id}","starred_url":"https://api.github.com/users/yershalom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yershalom/subscriptions","organizations_url":"https://api.github.com/users/yershalom/orgs","repos_url":"https://api.github.com/users/yershalom/repos","events_url":"https://api.github.com/users/yershalom/events{/privacy}","received_events_url":"https://api.github.com/users/yershalom/received_events","type":"User","site_admin":false},"repo":{"id":65813603,"name":"redash","full_name":"yershalom/redash","owner":{"login":"yershalom","id":7933604,"avatar_url":"https://avatars.githubusercontent.com/u/7933604?v=3","gravatar_id":"","url":"https://api.github.com/users/yershalom","html_url":"https://github.com/yershalom","followers_url":"https://api.github.com/users/yershalom/followers","following_url":"https://api.github.com/users/yershalom/following{/other_user}","gists_url":"https://api.github.com/users/yershalom/gists{/gist_id}","starred_url":"https://api.github.com/users/yershalom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yershalom/subscriptions","organizations_url":"https://api.github.com/users/yershalom/orgs","repos_url":"https://api.github.com/users/yershalom/repos","events_url":"https://api.github.com/users/yershalom/events{/privacy}","received_events_url":"https://api.github.com/users/yershalom/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yershalom/redash","description":"Make Your Company Data Driven. Connect to any data source, easily visualize and share your data.","fork":true,"url":"https://api.github.com/repos/yershalom/redash","forks_url":"https://api.github.com/repos/yershalom/redash/forks","keys_url":"https://api.github.com/repos/yershalom/redash/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yershalom/redash/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yershalom/redash/teams","hooks_url":"https://api.github.com/repos/yershalom/redash/hooks","issue_events_url":"https://api.github.com/repos/yershalom/redash/issues/events{/number}","events_url":"https://api.github.com/repos/yershalom/redash/events","assignees_url":"https://api.github.com/repos/yershalom/redash/assignees{/user}","branches_url":"https://api.github.com/repos/yershalom/redash/branches{/branch}","tags_url":"https://api.github.com/repos/yershalom/redash/tags","blobs_url":"https://api.github.com/repos/yershalom/redash/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yershalom/redash/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yershalom/redash/git/refs{/sha}","trees_url":"https://api.github.com/repos/yershalom/redash/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yershalom/redash/statuses/{sha}","languages_url":"https://api.github.com/repos/yershalom/redash/languages","stargazers_url":"https://api.github.com/repos/yershalom/redash/stargazers","contributors_url":"https://api.github.com/repos/yershalom/redash/contributors","subscribers_url":"https://api.github.com/repos/yershalom/redash/subscribers","subscription_url":"https://api.github.com/repos/yershalom/redash/subscription","commits_url":"https://api.github.com/repos/yershalom/redash/commits{/sha}","git_commits_url":"https://api.github.com/repos/yershalom/redash/git/commits{/sha}","comments_url":"https://api.github.com/repos/yershalom/redash/comments{/number}","issue_comment_url":"https://api.github.com/repos/yershalom/redash/issues/comments{/number}","contents_url":"https://api.github.com/repos/yershalom/redash/contents/{+path}","compare_url":"https://api.github.com/repos/yershalom/redash/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yershalom/redash/merges","archive_url":"https://api.github.com/repos/yershalom/redash/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yershalom/redash/downloads","issues_url":"https://api.github.com/repos/yershalom/redash/issues{/number}","pulls_url":"https://api.github.com/repos/yershalom/redash/pulls{/number}","milestones_url":"https://api.github.com/repos/yershalom/redash/milestones{/number}","notifications_url":"https://api.github.com/repos/yershalom/redash/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yershalom/redash/labels{/name}","releases_url":"https://api.github.com/repos/yershalom/redash/releases{/id}","deployments_url":"https://api.github.com/repos/yershalom/redash/deployments","created_at":"2016-08-16T11:09:58Z","updated_at":"2016-08-16T11:10:00Z","pushed_at":"2016-08-16T11:12:54Z","git_url":"git://github.com/yershalom/redash.git","ssh_url":"git@github.com:yershalom/redash.git","clone_url":"https://github.com/yershalom/redash.git","svn_url":"https://github.com/yershalom/redash","homepage":"http://redash.io/","size":9017,"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":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"getredash:master","ref":"master","sha":"dfb92dbb4e8fd675de81c1a8986dddea16adc9b6","user":{"login":"getredash","id":10746780,"avatar_url":"https://avatars.githubusercontent.com/u/10746780?v=3","gravatar_id":"","url":"https://api.github.com/users/getredash","html_url":"https://github.com/getredash","followers_url":"https://api.github.com/users/getredash/followers","following_url":"https://api.github.com/users/getredash/following{/other_user}","gists_url":"https://api.github.com/users/getredash/gists{/gist_id}","starred_url":"https://api.github.com/users/getredash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/getredash/subscriptions","organizations_url":"https://api.github.com/users/getredash/orgs","repos_url":"https://api.github.com/users/getredash/repos","events_url":"https://api.github.com/users/getredash/events{/privacy}","received_events_url":"https://api.github.com/users/getredash/received_events","type":"Organization","site_admin":false},"repo":{"id":13926404,"name":"redash","full_name":"getredash/redash","owner":{"login":"getredash","id":10746780,"avatar_url":"https://avatars.githubusercontent.com/u/10746780?v=3","gravatar_id":"","url":"https://api.github.com/users/getredash","html_url":"https://github.com/getredash","followers_url":"https://api.github.com/users/getredash/followers","following_url":"https://api.github.com/users/getredash/following{/other_user}","gists_url":"https://api.github.com/users/getredash/gists{/gist_id}","starred_url":"https://api.github.com/users/getredash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/getredash/subscriptions","organizations_url":"https://api.github.com/users/getredash/orgs","repos_url":"https://api.github.com/users/getredash/repos","events_url":"https://api.github.com/users/getredash/events{/privacy}","received_events_url":"https://api.github.com/users/getredash/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/getredash/redash","description":"Make Your Company Data Driven. Connect to any data source, easily visualize and share your data.","fork":false,"url":"https://api.github.com/repos/getredash/redash","forks_url":"https://api.github.com/repos/getredash/redash/forks","keys_url":"https://api.github.com/repos/getredash/redash/keys{/key_id}","collaborators_url":"https://api.github.com/repos/getredash/redash/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/getredash/redash/teams","hooks_url":"https://api.github.com/repos/getredash/redash/hooks","issue_events_url":"https://api.github.com/repos/getredash/redash/issues/events{/number}","events_url":"https://api.github.com/repos/getredash/redash/events","assignees_url":"https://api.github.com/repos/getredash/redash/assignees{/user}","branches_url":"https://api.github.com/repos/getredash/redash/branches{/branch}","tags_url":"https://api.github.com/repos/getredash/redash/tags","blobs_url":"https://api.github.com/repos/getredash/redash/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/getredash/redash/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/getredash/redash/git/refs{/sha}","trees_url":"https://api.github.com/repos/getredash/redash/git/trees{/sha}","statuses_url":"https://api.github.com/repos/getredash/redash/statuses/{sha}","languages_url":"https://api.github.com/repos/getredash/redash/languages","stargazers_url":"https://api.github.com/repos/getredash/redash/stargazers","contributors_url":"https://api.github.com/repos/getredash/redash/contributors","subscribers_url":"https://api.github.com/repos/getredash/redash/subscribers","subscription_url":"https://api.github.com/repos/getredash/redash/subscription","commits_url":"https://api.github.com/repos/getredash/redash/commits{/sha}","git_commits_url":"https://api.github.com/repos/getredash/redash/git/commits{/sha}","comments_url":"https://api.github.com/repos/getredash/redash/comments{/number}","issue_comment_url":"https://api.github.com/repos/getredash/redash/issues/comments{/number}","contents_url":"https://api.github.com/repos/getredash/redash/contents/{+path}","compare_url":"https://api.github.com/repos/getredash/redash/compare/{base}...{head}","merges_url":"https://api.github.com/repos/getredash/redash/merges","archive_url":"https://api.github.com/repos/getredash/redash/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/getredash/redash/downloads","issues_url":"https://api.github.com/repos/getredash/redash/issues{/number}","pulls_url":"https://api.github.com/repos/getredash/redash/pulls{/number}","milestones_url":"https://api.github.com/repos/getredash/redash/milestones{/number}","notifications_url":"https://api.github.com/repos/getredash/redash/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/getredash/redash/labels{/name}","releases_url":"https://api.github.com/repos/getredash/redash/releases{/id}","deployments_url":"https://api.github.com/repos/getredash/redash/deployments","created_at":"2013-10-28T13:19:39Z","updated_at":"2016-08-16T11:34:16Z","pushed_at":"2016-08-16T11:12:55Z","git_url":"git://github.com/getredash/redash.git","ssh_url":"git@github.com:getredash/redash.git","clone_url":"https://github.com/getredash/redash.git","svn_url":"https://github.com/getredash/redash","homepage":"http://redash.io/","size":9017,"stargazers_count":2063,"watchers_count":2063,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":387,"mirror_url":null,"open_issues_count":139,"forks":387,"open_issues":139,"watchers":2063,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/getredash/redash/pulls/1236"},"html":{"href":"https://github.com/getredash/redash/pull/1236"},"issue":{"href":"https://api.github.com/repos/getredash/redash/issues/1236"},"comments":{"href":"https://api.github.com/repos/getredash/redash/issues/1236/comments"},"review_comments":{"href":"https://api.github.com/repos/getredash/redash/pulls/1236/comments"},"review_comment":{"href":"https://api.github.com/repos/getredash/redash/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/getredash/redash/pulls/1236/commits"},"statuses":{"href":"https://api.github.com/repos/getredash/redash/statuses/87d77d4d27e7c986b922d3be68b04ec99ea8a1e6"}}}}
{"actor":{"display_login":"arikfr"}}