Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError: global name 'cassandra' is not defined #1422

Closed
chemipot opened this issue Nov 23, 2016 · 5 comments
Closed

NameError: global name 'cassandra' is not defined #1422

chemipot opened this issue Nov 23, 2016 · 5 comments

Comments

@chemipot
Copy link

chemipot commented Nov 23, 2016

Hey,

Issue Summary

I added export REDASH_ADDITIONAL_QUERY_RUNNERS=redash.query_runner.cass to opt/redash/.env. After that, I was able to create a new cassandra datasource but when querying is failing and displaying: global name 'cassandra' is not defined

I have installed the DataStax Cassandra driver sudo pip install cassandra-driver and using Python 2.7.6.

These are the traces of /opt/redash/logs/celery_error.log

2016-11-23 02:09:15,625: WARNING/Worker-5] Unexpected error while running query:
Traceback (most recent call last):
  File "/opt/redash/redash.0.12.0.b2449/redash/tasks/queries.py", line 410, in run
    data, error = query_runner.run_query(annotated_query, self.user)
  File "/opt/redash/redash.0.12.0.b2449/redash/query_runner/cass.py", line 90, in run_query
    except cassandra.cluster.Error, e:
NameError: global name 'cassandra' is not defined

Technical details

  • Redash version 0.12.0+b2449
  • OS Ubuntu 3.13.0-88-generic / Browser: Chrome.
  • How did you install Redash: running the provisioning script

Thanks

@arikfr
Copy link
Member

arikfr commented Nov 23, 2016

If you run python -c "import cassandra" is it working?

@chemipot
Copy link
Author

If you run python -c "import cassandra" is it working?

Yes

@arikfr
Copy link
Member

arikfr commented Nov 23, 2016

#1423 fixes this. The problem was that the cassandra.cluster.Error exception wasn't imported. You can replace your /opt/redash/current/redash/query_runner/cass.py file with the one from the pull request or just add the relevant import statement (I did several other small structure fixes in this pull request).

@arikfr
Copy link
Member

arikfr commented Nov 23, 2016

(this issue only happens if you have an exception while connecting/running the query)

@sivasankar95
Copy link

I too have the same issue after running python -c "import cassandra" then too its showing the same error.
Connection Test Failed:
global name 'cassandra' is not defined
[2016-12-19 15:47:43,817: WARNING/Worker-11] Unexpected error while running query:
Traceback (most recent call last):
File "/opt/redash/redash.0.12.0.b2449/redash/tasks/queries.py", line 410, in run
data, error = query_runner.run_query(annotated_query, self.user)
File "/opt/redash/redash.0.12.0.b2449/redash/query_runner/cass.py", line 90, in run_query
except cassandra.cluster.Error, e:
NameError: global name 'cassandra' is not defined

dairyo pushed a commit to KiiCorp/redash that referenced this issue Mar 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants