Giter Club home page Giter Club logo

Comments (7)

r4fek avatar r4fek commented on July 20, 2024

Hi Dominick,

thanks for your input! I'll implement support for auth_provider in very near future. Stay tuned!

from django-cassandra-engine.

r4fek avatar r4fek commented on July 20, 2024

In the meantime you can add PlainTextAuthProvider (described here: http://datastax.github.io/python-driver/api/cassandra/auth.html#cassandra.auth.PlainTextAuthProvider) to connection options. Let me know if it solves your problem.

I'll add this option automatically if USER and PASSWORD options are set.

from django-cassandra-engine.

drivard avatar drivard commented on July 20, 2024

Yes I saw that this morning. I hadn't time yet to implement it completely
I'll finish the code and publish an example later tonight.

Thanks
Dominick

from django-cassandra-engine.

drivard avatar drivard commented on July 20, 2024

Here is how to get it to work:
At the top of your settings.py file import the Authenticator class:

from cassandra.auth import PlainTextAuthProvider

Once the Authenticator class is imported you can tweak your database connection like the following.

DATABASES = {
    'default': {
        'ENGINE': 'django_cassandra_engine',
        'NAME': 'mykeyspace',
        'USER': 'user',
        'PASSWORD': 'password',
        'HOST': '127.0.0.1',  # comma separeted hosts
        'OPTIONS': {
            'replication': {
                'strategy_class': 'SimpleStrategy',
                'replication_factor': 1
            },
            'connection': {
                'consistency': ConsistencyLevel.ONE,
                'lazy_connect': True,
                'retry_connect': True,
                'port': 9042,
                'auth_provider': PlainTextAuthProvider(username='user', password='password'),
                # + All connection options for cassandra.Cluster()
            }
        }
    }
}

In my case the python manage.py syncdb command line returned

python manage.py syncdb
Creating keyspace mykeyspace..

Thanks for your help, I am closing the issue.

Best
Dominick

from django-cassandra-engine.

r4fek avatar r4fek commented on July 20, 2024

Try the new version 0.1.4. Just add USER and PASSWORD, no need to define auth_provider in connection options.
Thanks for your contribution!

from django-cassandra-engine.

drivard avatar drivard commented on July 20, 2024

I confirm this works using the following connection pattern:

DATABASES = {
    'default': {
        'ENGINE': 'django_cassandra_engine',
        'NAME': 'mykeyspace',
        'USER': 'user',
        'PASSWORD': 'password',
        'HOST': '127.0.0.1',  # comma separeted hosts
        'OPTIONS': {
            'replication': {
                'strategy_class': 'SimpleStrategy',
                'replication_factor': 1
            },
            'connection': {
                'consistency': ConsistencyLevel.ONE,
                'lazy_connect': True,
                'retry_connect': True,
                'port': 9042,
                # + All connection options for cassandra.Cluster()
            }
        }
    }
}

No more need to import from cassandra.auth import PlainTextAuthProvider in the settings.py file.

Thanks
Dominick

from django-cassandra-engine.

drivard avatar drivard commented on July 20, 2024

Thanks Rafal the fast fix is really appreciated.

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.