django-cassandra-engine
django-cassandra-engine copied to clipboard
python manage.py inspectdb does not show the models of Cassandra
I ran manage.py inspectdb but it only showed all those migrated in the Relational Database
(django-cassandra)Deans-MacBook:tutorial deanarmada$ python manage.py inspectdb
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# * Make sure each ForeignKey has `on_delete` set to the desired behavior.
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from __future__ import unicode_literals
from django.db import models
class AuthGroup(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
name = models.CharField(unique=True, max_length=80)
class Meta:
managed = False
db_table = 'auth_group'
class AuthGroupPermissions(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
group = models.ForeignKey(AuthGroup, models.DO_NOTHING)
permission = models.ForeignKey('AuthPermission', models.DO_NOTHING)
class Meta:
managed = False
db_table = 'auth_group_permissions'
unique_together = (('group', 'permission'),)
class AuthPermission(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
content_type = models.ForeignKey('DjangoContentType', models.DO_NOTHING)
codename = models.CharField(max_length=100)
name = models.CharField(max_length=255)
class Meta:
managed = False
db_table = 'auth_permission'
unique_together = (('content_type', 'codename'),)
class AuthUser(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
password = models.CharField(max_length=128)
last_login = models.DateTimeField(blank=True, null=True)
is_superuser = models.BooleanField()
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
email = models.CharField(max_length=254)
is_staff = models.BooleanField()
is_active = models.BooleanField()
date_joined = models.DateTimeField()
username = models.CharField(unique=True, max_length=150)
class Meta:
managed = False
db_table = 'auth_user'
class AuthUserGroups(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
user = models.ForeignKey(AuthUser, models.DO_NOTHING)
group = models.ForeignKey(AuthGroup, models.DO_NOTHING)
class Meta:
managed = False
db_table = 'auth_user_groups'
unique_together = (('user', 'group'),)
class AuthUserUserPermissions(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
user = models.ForeignKey(AuthUser, models.DO_NOTHING)
permission = models.ForeignKey(AuthPermission, models.DO_NOTHING)
class Meta:
managed = False
db_table = 'auth_user_user_permissions'
unique_together = (('user', 'permission'),)
class DjangoAdminLog(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
object_id = models.TextField(blank=True, null=True)
object_repr = models.CharField(max_length=200)
action_flag = models.PositiveSmallIntegerField()
change_message = models.TextField()
content_type = models.ForeignKey('DjangoContentType', models.DO_NOTHING, blank=True, null=True)
user = models.ForeignKey(AuthUser, models.DO_NOTHING)
action_time = models.DateTimeField()
class Meta:
managed = False
db_table = 'django_admin_log'
class DjangoContentType(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
app_label = models.CharField(max_length=100)
model = models.CharField(max_length=100)
class Meta:
managed = False
db_table = 'django_content_type'
unique_together = (('app_label', 'model'),)
class DjangoMigrations(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
app = models.CharField(max_length=255)
name = models.CharField(max_length=255)
applied = models.DateTimeField()
class Meta:
managed = False
db_table = 'django_migrations'
class DjangoSession(models.Model):
session_key = models.CharField(primary_key=True, max_length=40)
session_data = models.TextField()
expire_date = models.DateTimeField()
class Meta:
managed = False
db_table = 'django_session'
I tried specifying inspecting the db of cassandra
(django-cassandra)Deans-MacBook:tutorial deanarmada$ python manage.py inspectdb --database cassandra
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# * Make sure each ForeignKey has `on_delete` set to the desired behavior.
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from __future__ import unicode_literals
from django.db import models
Here is a proof that I have a table in my cassandra:
(django-cassandra)Deans-MacBook:tutorial deanarmada$ python manage.py dbshell --database cassandra
Warning: Timezone defined and 'pytz' module for timezone conversion not installed. Timestamps will be displayed in UTC timezone.
Connected to Test Cluster at 192.168.1.110:9042.
[cqlsh 5.0.1 | Cassandra 3.5 | CQL spec 3.4.0 | Native protocol v4]
Use HELP for help.
cqlsh:db> SELECT * FROM example_model;
example_id | created_at | description | example_type
--------------------------------------+------------+-------------+---------------------------------
a2fa57e3-41a7-4e25-911e-4661daf2f44e | 2016-08-22 | example7 | 1970-01-01 00:00:00.001000+0000
94b5d30d-22b7-4519-87bb-15ae92634818 | 2016-08-22 | example2 | 1970-01-01 00:00:00.000000+0000
c295c622-6f34-4425-bef4-15c47bb4e1c8 | 2016-08-22 | example8 | 1970-01-01 00:00:00.001000+0000
6b145983-f1f3-43ed-95ee-a1d4e50d3ba9 | 2016-08-22 | example4 | 1970-01-01 00:00:00.000000+0000
f01756f1-6450-42ec-9da3-bb460f970444 | 2016-08-22 | example3 | 1970-01-01 00:00:00.000000+0000
8ba3af60-cb17-4bcd-8405-6ba830f509c6 | 2016-08-22 | example5 | 1970-01-01 00:00:00.001000+0000
0bb1adaa-44f2-4870-b8a6-4ab11147c88b | 2016-08-22 | example6 | 1970-01-01 00:00:00.001000+0000
078bddad-f7c1-4271-9c74-ac5a6f37838d | 2016-08-22 | example1 | 1970-01-01 00:00:00.000000+0000
(8 rows)
cqlsh:db>
Here is my models.py:
from __future__ import unicode_literals
from django.db import models
from cassandra.cqlengine import columns
from cassandra.cqlengine.models import Model
import uuid
# Create your models here.
class ExampleModel(Model):
read_repair_chance = 0.05
example_id = columns.UUID(primary_key=True, default=uuid.uuid4)
example_type = columns.Integer(index=True)
created_at = columns.Date()
description = columns.Text(required=False)
Here is my DATABASE settings:
from cassandra import ConsistencyLevel
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
},
'cassandra': {
'ENGINE': 'django_cassandra_engine',
'NAME': 'db',
'TEST_NAME': 'test_db',
'HOST': '192.168.1.110,192.168.1.111,192.168.1.112',
'OPTIONS': {
'replication': {
'strategy_class': 'SimpleStrategy',
'replication_factor': 1
},
'connection': {
'consistency': ConsistencyLevel.LOCAL_ONE,
'retry_connect': True
# + All connection options for cassandra.cluster.Cluster()
},
'session': {
'default_timeout': 10,
'default_fetch_size': 10000
# + All options for cassandra.cluster.Session()
}
}
}
}
even i am facing the same.
Facing the same issue here.
Same problem here.
The doc is talking about a working inspectdb command. The applications seems to be getting a proper working cassandra connection, but I'm getting an empty models output. ¿Some hints?
VERSIONS
django==1.11.10 django-cassandra-engine==1.4.0 cassandra-driver==3.13.0
` python3 manage.py inspectdb --database cassandra [05/Apr/2018 10:15:00] cassandra.cluster WARNING Cluster.init called with contact_points specified, but no loa error; please specify a load-balancing policy. (contact_points = ['127.0.0.1'], lbp = None) [05/Apr/2018 10:15:00] cassandra.policies INFO Using datacenter 'datacenter1' for
Feel free to rename the models, but don't rename db_table values or field names. from future import unicode_literals
from django.db import models `
Obviously that cassandra keyspace contains several tables.
Thank You in advance.
I am facing the same issue. Can someone please help?
Same issue here too, please help
I am also facing the same issue in latest build, seems this is not yet solved.
Facing the same issue here, did anyone solve it? Thanks
@r4fek I think the issue here is that every custom defined class of the users donot migrate into Cassandra, only those which Inerhit the Cassandra models reflect which clearly means we need to find a way that'd allow us to create migrations for those which inherit models.Model class
same here