Closed baali closed 8 years ago
Hi @baali,
thanks for your report.
Are you sure you set up DATABASES
dict in settings.py
correctly? Could you paste it?
If cassandra_connection.connected
is set to True
, then cqlengine.connection.setup
is being called for sure.
@baali please try this from shell:
from django.db import connection
connection.connect()
and let me know if it works. This will work if your only database is cassandra. If not:
from django.db import connections
connections['cassandra'].connect()
Hello @r4fek
Thank you for getting back. Yes doing
connections['cassandra'].connect()
Worked. But trying to run a count query is still throwing up same CQLEngineException. My DATABASES dict in settings.py is this:
'cassandra': {'ATOMIC_REQUESTS': False, 'AUTOCOMMIT': True, 'CONN_MAX_AGE': 0, 'ENGINE': 'django_cassandra_engine', 'HOST': 'localhost', 'NAME': 'playground', 'OPTIONS': {'connection': {'auth_provider': <cassandra.auth.PlainTextAuthProvider at 0x7f7e0c2a7690>, 'consistency': 10, 'lazy_connect': True, 'protocol_version': 3, 'retry_connect': True}, 'replication': {'replication_factor': 1, 'strategy_class': 'SimpleStrategy'}, 'session': {'default_fetch_size': 10000, 'default_timeout': 20}}, 'PASSWORD': 'pass', 'PORT': '', 'TEST': {'CHARSET': None, 'COLLATION': None, 'MIRROR': None, 'NAME': 'test_db'}, 'TIME_ZONE': 'UTC', 'USER': 'user'},
@baali I checked the testproject from this repo with cassandra as secondary backend:
$ cd django-cassandra-engine/testproject
$ export DJANGO_SETTINGS_MODULE="settings.secondary_cassandra"
$ python manage.py sync_cassandra
Creating keyspace db..
Syncing app.models.ExampleModel
Syncing app.models.ExampleModel2
Syncing app.models.TestProjectModel
$ python manage.py shell
Python 2.7.8 (default, Oct 20 2014, 15:05:19)
[GCC 4.9.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from app.models import *
>>> ExampleModel.objects.create(id=1)
ExampleModel(id=1, created_at=None, deleted=False)
>>> list(ExampleModel.objects.all())
[ExampleModel(id=1, created_at=None, deleted=False)]
As you can see it worked out of the box.
My pip freeze
is:
Django==1.7.7
Jinja2==2.8
Markdown==2.6.2
MarkupSafe==0.23
PyYAML==3.11
argparse==1.2.1
backports.ssl-match-hostname==3.4.0.2
blist==1.3.6
cassandra-driver==3.0.0
certifi==2015.04.28
click==5.1
cqlengine==0.21.0
django-cassandra-engine==0.6.0
djangotoolbox==1.6.2
futures==3.0.3
livereload==2.4.0
mkdocs==0.14.0
mock==1.0.1
six==1.10.0
tornado==4.2.1
wsgiref==0.1.2
Could you confirm that this works for you too?
Hello @r4fek Yes this works for me too.
[baali@jugaad] [~/analytics/django-cassandra-engine/testproject]
$ export DJANGO_SETTINGS_MODULE="settings.secondary_cassandra"
(tsenv)[baali@jugaad] [~/analytics/django-cassandra-engine/testproject]
$ python manage.py sync_cassandra
Creating keyspace db..
Syncing app.models.ExampleModel
Syncing app.models.ExampleModel2
Syncing app.models.TestProjectModel
(tsenv)[baali@jugaad] [~/analytics/django-cassandra-engine/testproject]
$ python manage.py shell
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.2 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from app.models import *
In [2]: ExampleModel.objects.create(id=1)
Out[2]: ExampleModel(id=1, created_at=None, deleted=False)
In [3]: list(ExampleModel.objects.all())
Out[3]: [ExampleModel(id=1, created_at=None, deleted=False)]
My pip freeze is:
$ pip freeze|grep cass
cassandra-driver==3.0.0
django-cassandra-engine==0.6.0
$ pip freeze | grep Django
Django==1.7.7
$ pip freeze | grep cql
cqlengine==0.21.0
I am not sure, seems like there is some issue with my configs/local setup. Sorry for the trouble I will try to cross check and update the thread.
Hi, @baali. Any updates on this? Did you manage to fix it?
Hey @r4fek. No, I started making direct queries. Sorry for the trouble, closing this.
Hello,
I have django_cassandra_engine version 0.6.3 with 3.0 cassandra-driver and Django1.7 installed. With previous versions of django_cassandra_engine views involving Cassandra Models uses to work out of box but with the updates I am getting
CQLEngineException: It is required to setup() cqlengine before executing queries
From manage.py shell I have tried to do things manually but still same error:Doing setup directly and running the query works.
What am I missing?