Giter VIP home page Giter VIP logo

Comments (7)

r4fek avatar r4fek commented on July 20, 2024

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.

from django-cassandra-engine.

r4fek avatar r4fek commented on July 20, 2024

@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()

from django-cassandra-engine.

baali avatar baali commented on July 20, 2024

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'},

from django-cassandra-engine.

r4fek avatar r4fek commented on July 20, 2024

@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?

from django-cassandra-engine.

baali avatar baali commented on July 20, 2024

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.

from django-cassandra-engine.

r4fek avatar r4fek commented on July 20, 2024

Hi, @baali. Any updates on this? Did you manage to fix it?

from django-cassandra-engine.

baali avatar baali commented on July 20, 2024

Hey @r4fek. No, I started making direct queries. Sorry for the trouble, closing this.

from django-cassandra-engine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.