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

django cassnadra migration #150

Open
antonzhelyazkov opened this issue Sep 29, 2021 · 1 comment
Open

django cassnadra migration #150

antonzhelyazkov opened this issue Sep 29, 2021 · 1 comment

Comments

@antonzhelyazkov
Copy link

Hi I am new in django

I tried to connect django to cassandra.
here are my modules:

cassandra-driver (3.25.0)
cassandra-pylib (0.0.0)
click (8.0.1)
Django (3.2.7)
django-cassandra-engine (1.6.3)

here are my settings.py


INSTALLED_APPS = ['django_cassandra_engine'] + INSTALLED_APPS

DATABASES = {
    # 'default': {
    #     'ENGINE': 'django.db.backends.sqlite3',
    #     'NAME': BASE_DIR / 'db.sqlite3',
    # }
    'default': {
        'ENGINE': 'django_cassandra_engine',
        'NAME': 'dvr',
        'HOST': '127.0.0.1',
        'USER': 'user',
        'PASSWORD': 'pass',
        'OPTIONS': {
            'replication': {
                'strategy_class': 'NetworkTopologyStrategy',
                'dc1': 1
            },
            'connection': {
                    'consistency': ConsistencyLevel.LOCAL_ONE,
                    'retry_connect': True,
                    'protocol_version': 4
                    # + All connection options for cassandra.cluster.Cluster()
            }
        }
    }
}

when I try to run migrations I have an error:

/root/python38/bin/python3 /root/cutter2/cutter/manage.py sync_cassandra
Creating keyspace dvr [CONNECTION default] ..
/root/python38/bin/python3 /root/cutter2/cutter/manage.py migrate
Migrations are not supported in this engine. Calling syncdb instead..
Traceback (most recent call last):
  File "/root/cutter2/cutter/manage.py", line 22, in <module>
    main()
  File "/root/cutter2/cutter/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/root/python38/lib64/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/root/python38/lib64/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/root/python38/lib64/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/root/python38/lib64/python3.8/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/root/python38/lib64/python3.8/site-packages/django_cassandra_engine/management/commands/migrate.py", line 17, in handle
    call_command('sync_cassandra', **options)
  File "/root/python38/lib64/python3.8/site-packages/django/core/management/__init__.py", line 168, in call_command
    raise TypeError(
TypeError: Unknown option(s) for sync_cassandra command: app_label, check_unapplied, fake, fake_initial, interactive, migration_name, plan, run_syncdb. Valid options are: database, force_color, help, no_color, pythonpath, settings, skip_checks, stderr, stdout, traceback, verbosity, version.

Could you help me to run migrations

@r4fek
Copy link
Owner

r4fek commented Oct 21, 2021

Hello! You don't need to run migrations. python manage.py sync_cassandra does the trick for you, so every time you add a column to your model you have to call sync_cassandra and that's it.

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

2 participants