djongo.sql2mongo.SQLDecodeError on runserver of fresh project
One line description of the issue
sql decode error (see stack trace)
Python script
python manage.py runserver
Running latest django and djongo on python 3.7.0 Running older version of mongo db, 'version': '3.2.12' , could this be the cause?
Traceback
Django version 2.0.7, using settings 'content_services.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. Internal Server Error: /admin/ Traceback (most recent call last): File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 725, in iter yield from iter(self._query) File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 159, in iter self._cursor = self._get_cursor() File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 258, in _get_cursor cur = self.db_ref[self.left_table].aggregate(pipeline) File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/pymongo/collection.py", line 2397, in aggregate **kwargs) File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/pymongo/collection.py", line 2304, in _aggregate client=self.__database.client) File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/pymongo/pool.py", line 579, in command unacknowledged=unacknowledged) File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/pymongo/network.py", line 150, in command parse_write_concern_error=parse_write_concern_error) File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/pymongo/helpers.py", line 155, in _check_command_response raise OperationFailure(msg % errmsg, code, response) pymongo.errors.OperationFailure: Unrecognized pipeline stage name: '$addFields'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/core/handlers/base.py", line 158, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/core/handlers/base.py", line 156, in _get_response
response = response.render()
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/response.py", line 106, in render
self.content = self.rendered_content
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/response.py", line 83, in rendered_content
content = template.render(context, self._request)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/backends/django.py", line 61, in render
return self.template.render(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/base.py", line 175, in render
return self._render(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/base.py", line 167, in _render
return self.nodelist.render(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/base.py", line 943, in render
bit = node.render_annotated(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/base.py", line 910, in render_annotated
return self.render(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/loader_tags.py", line 155, in render
return compiled_parent._render(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/base.py", line 167, in _render
return self.nodelist.render(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/base.py", line 943, in render
bit = node.render_annotated(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/base.py", line 910, in render_annotated
return self.render(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/loader_tags.py", line 155, in render
return compiled_parent._render(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/base.py", line 167, in _render
return self.nodelist.render(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/base.py", line 943, in render
bit = node.render_annotated(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/base.py", line 910, in render_annotated
return self.render(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/loader_tags.py", line 67, in render
result = block.nodelist.render(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/base.py", line 943, in render
bit = node.render_annotated(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/base.py", line 910, in render_annotated
return self.render(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/defaulttags.py", line 314, in render
return nodelist.render(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/base.py", line 943, in render
bit = node.render_annotated(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/base.py", line 910, in render_annotated
return self.render(context)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/template/defaulttags.py", line 168, in render
len_values = len(values)
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/db/models/query.py", line 254, in len
self._fetch_all()
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/db/models/query.py", line 1179, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/db/models/query.py", line 62, in iter
for row in compiler.results_iter(results):
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1007, in apply_converters
for row in map(list, rows):
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1462, in cursor_iter
for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
File "/Users/rwojcik/.local/share/virtualenvs/content_services-QwWaFh_z/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1462, in
me to Sometimes refresh frshdjongo.sql2mongo.SQLDecodeError: FAILED SQL Version: 1.2.30 pymongo==3.6.1 django==2.0.5 djongo==1.2.30
@hellonts @radzhome
I guess the problem may be the version of sqlparse -- sqlparse 0.2.4 works well, but sqlparse 0.3.0 not.
Ok Thanks.
| | Alen | | 邮箱:[email protected] |
Signature is customized by Netease Mail Master
On 03/13/2019 10:07, abawchen wrote:
@hellonts@radzhome I guess the problem may be the version of sqlparse -- sqlparse 0.2.4 works well, but sqlparse 0.3.0 not.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 763, in parse return handler(self, statement) File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 805, in _create self.db.create_collection(table) File "/usr/local/lib/python3.7/site-packages/pymongo/database.py", line 373, in create_collection raise CollectionInvalid("collection %s already exists" % name) pymongo.errors.CollectionInvalid: collection payment_checkout already exists
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 15, in
please help me to solve this issue
@rajat45mishra I'm facing the same issue
@artemnesterenko You can't use mptt module with mongodb you have to write a database router for switching SQL and nosql database . You can find examples of database routers in Django documentation
@artemnesterenko You can't use mptt module with mongodb you have to write a database router for switching SQL and nosql database . You can find examples of database routers in Django documentation
I'm already using routers:
class BaseMongoRouter:
mongo_models = None
def db_for_read(self, model, **hints) -> Optional[str]:
if self.is_mongo_model(model=model):
return settings.MONGO_DB_ALIAS
return None
def db_for_write(self, model, **hints) -> Optional[str]:
if self.is_mongo_model(model=model):
return settings.MONGO_DB_ALIAS
return None
def allow_relation(self, obj1, obj2, **hints) -> Optional[bool]:
return None
def allow_migrate(self, db, app_label, model_name=None, **hints) -> Optional[bool]:
"""Deny all migrations for mongodb and mongo-related models."""
is_mongo_db = db == settings.MONGO_DB_ALIAS
is_mongo_model = self.is_mongo_model(app_label=app_label, model_name=model_name)
if is_mongo_db and is_mongo_model:
return getattr(settings, "TEST", False)
if is_mongo_db or is_mongo_model:
return False
return None
def is_mongo_model(self, *, model=None, app_label=None, model_name=None) -> bool:
if not model and not app_label:
raise ValueError("Provide either model or app_label")
if model:
return model in self.mongo_models
label_model_set = {
(m._meta.app_label, m._meta.model_name) for m in self.mongo_models
}
return (app_label, model_name) in label_model_set
I allow migrations for mongo models only during testing to not create all tables in tests manually. Everything works fine except the test mongo db instantiation when the exception occurs.
When I run tests with an empty test db, I get:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 806, in parse
return handler(self, statement)
File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 869, in _create
type_code = props[1]
IndexError: list index out of range
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 17, in <module>
main()
File "manage.py", line 13, in main
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/test.py", line 23, in run_from_argv
super().run_from_argv(argv)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/test.py", line 53, in handle
failures = test_runner.run_tests(test_labels)
File "/usr/local/lib/python3.7/site-packages/django/test/runner.py", line 629, in run_tests
old_config = self.setup_databases(aliases=databases)
File "/usr/local/lib/python3.7/site-packages/django/test/runner.py", line 554, in setup_databases
self.parallel, **kwargs
File "/usr/local/lib/python3.7/site-packages/django/test/utils.py", line 174, in setup_databases
serialize=connection.settings_dict.get('TEST', {}).get('SERIALIZE', True),
File "/usr/local/lib/python3.7/site-packages/django/db/backends/base/creation.py", line 72, in create_test_db
run_syncdb=True,
File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 148, in call_command
return command.execute(*args, **defaults)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 234, in handle
fake_initial=fake_initial,
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 245, in apply_migration
state = migration.apply(state, schema_editor)
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/migration.py", line 124, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/operations/models.py", line 92, in database_forwards
schema_editor.create_model(model)
File "/usr/local/lib/python3.7/site-packages/django/db/backends/base/schema.py", line 307, in create_model
self.execute(sql, params or None)
File "/usr/local/lib/python3.7/site-packages/django/db/backends/base/schema.py", line 137, in execute
cursor.execute(sql, params)
File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 82, in _execute
return self.cursor.execute(sql)
File "/usr/local/lib/python3.7/site-packages/djongo/cursor.py", line 53, in execute
params)
File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 743, in __init__
self.parse()
File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 826, in parse
raise exe from e
djongo.sql2mongo.SQLDecodeError: FAILED SQL: CREATE TABLE "table_name" ()
Version: 1.2.32
artemnesterenko can you show me your models.py file
Or try version 1.2.31
Or try version 1.2.31
Creating test database for alias 'mongo'...
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 769, in parse
return handler(self, statement)
File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 894, in _insert
self._query.execute()
File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 433, in execute
res = self.db_ref[self.left_table].insert_many(docs, ordered=False)
File "/usr/local/lib/python3.7/site-packages/pymongo/collection.py", line 745, in insert_many
raise TypeError("documents must be a non-empty list")
TypeError: documents must be a non-empty list
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 17, in <module>
main()
File "manage.py", line 13, in main
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/test.py", line 23, in run_from_argv
super().run_from_argv(argv)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/test.py", line 53, in handle
failures = test_runner.run_tests(test_labels)
File "/usr/local/lib/python3.7/site-packages/django/test/runner.py", line 629, in run_tests
old_config = self.setup_databases(aliases=databases)
File "/usr/local/lib/python3.7/site-packages/django/test/runner.py", line 554, in setup_databases
self.parallel, **kwargs
File "/usr/local/lib/python3.7/site-packages/django/test/utils.py", line 174, in setup_databases
serialize=connection.settings_dict.get('TEST', {}).get('SERIALIZE', True),
File "/usr/local/lib/python3.7/site-packages/django/db/backends/base/creation.py", line 72, in create_test_db
run_syncdb=True,
File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 148, in call_command
return command.execute(*args, **defaults)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 234, in handle
fake_initial=fake_initial,
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 246, in apply_migration
self.record_migration(migration)
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 261, in record_migration
self.recorder.record_applied(migration.app_label, migration.name)
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/recorder.py", line 83, in record_applied
self.migration_qs.create(app=app, name=name)
File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 422, in create
obj.save(force_insert=True, using=self.db)
File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 741, in save
force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 779, in save_base
force_update, using, update_fields,
File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 870, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 908, in _do_insert
using=using, raw=raw)
File "/usr/local/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 1186, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1332, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.7/site-packages/djongo/cursor.py", line 53, in execute
params)
File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 706, in __init__
self.parse()
File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 789, in parse
raise exe from e
djongo.sql2mongo.SQLDecodeError: FAILED SQL: INSERT INTO "django_migrations" ("app", "name", "applied") VALUES (%(0)s, %(1)s, %(2)s)
Version: 1.2.31
Document should not be empty
On Mon, May 27, 2019, 8:48 PM Artem Nesterenko [email protected] wrote:
Or try version 1.2.31
Creating test database for alias 'mongo'... Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 769, in parse return handler(self, statement) File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 894, in _insert self._query.execute() File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 433, in execute res = self.db_ref[self.left_table].insert_many(docs, ordered=False) File "/usr/local/lib/python3.7/site-packages/pymongo/collection.py", line 745, in insert_many raise TypeError("documents must be a non-empty list")TypeError: documents must be a non-empty list
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "manage.py", line 17, in
main() File "manage.py", line 13, in main execute_from_command_line(sys.argv) File "/usr/local/lib/python3.7/site-packages/django/core/management/init.py", line 381, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.7/site-packages/django/core/management/init.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/test.py", line 23, in run_from_argv super().run_from_argv(argv) File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute output = self.handle(*args, **options) File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/test.py", line 53, in handle failures = test_runner.run_tests(test_labels) File "/usr/local/lib/python3.7/site-packages/django/test/runner.py", line 629, in run_tests old_config = self.setup_databases(aliases=databases) File "/usr/local/lib/python3.7/site-packages/django/test/runner.py", line 554, in setup_databases self.parallel, **kwargs File "/usr/local/lib/python3.7/site-packages/django/test/utils.py", line 174, in setup_databases serialize=connection.settings_dict.get('TEST', {}).get('SERIALIZE', True), File "/usr/local/lib/python3.7/site-packages/django/db/backends/base/creation.py", line 72, in create_test_db run_syncdb=True, File "/usr/local/lib/python3.7/site-packages/django/core/management/init.py", line 148, in call_command return command.execute(*args, **defaults) File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute output = self.handle(*args, **options) File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 83, in wrapped res = handle_func(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 234, in handle fake_initial=fake_initial, File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 117, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 246, in apply_migration self.record_migration(migration) File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 261, in record_migration self.recorder.record_applied(migration.app_label, migration.name) File "/usr/local/lib/python3.7/site-packages/django/db/migrations/recorder.py", line 83, in record_applied self.migration_qs.create(app=app, name=name) File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 422, in create obj.save(force_insert=True, using=self.db) File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 741, in save force_update=force_update, update_fields=update_fields) File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 779, in save_base force_update, using, update_fields, File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 870, in _save_table result = self._do_insert(cls._base_manager, using, fields, update_pk, raw) File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 908, in _do_insert using=using, raw=raw) File "/usr/local/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 1186, in _insert return query.get_compiler(using=using).execute_sql(return_id) File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1332, in execute_sql cursor.execute(sql, params) File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 67, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers return executor(sql, params, many, context) File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/usr/local/lib/python3.7/site-packages/djongo/cursor.py", line 53, in execute params) File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 706, in init self.parse() File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 789, in parse raise exe from e djongo.sql2mongo.SQLDecodeError: FAILED SQL: INSERT INTO "django_migrations" ("app", "name", "applied") VALUES (%(0)s, %(1)s, %(2)s) Version: 1.2.31 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nesdis/djongo/issues/156?email_source=notifications&email_token=ALTOXN5JHYKCO62AXX4UFY3PXP3U5A5CNFSM4FJIFVWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWKBRUQ#issuecomment-496244946, or mute the thread https://github.com/notifications/unsubscribe-auth/ALTOXN5367FOVE63BEQDHR3PXP3U5ANCNFSM4FJIFVWA .
Document should not be empty
Yeah, I see :)
djongo.sql2mongo.SQLDecodeError: FAILED SQL: INSERT INTO "django_migrations" ("app", "name", "applied") VALUES (%(0)s, %(1)s, %(2)s)
But this happens during inserting into "django_migrations" table which is made by djongo and I don't have control over it.
I solved that issue with degrading version
On Mon, May 27, 2019, 8:59 PM Artem Nesterenko [email protected] wrote:
Document should not be empty Yeah, I see :)
djongo.sql2mongo.SQLDecodeError: FAILED SQL: INSERT INTO "django_migrations" ("app", "name", "applied") VALUES (%(0)s, %(1)s, %(2)s)
But this happens during inserting into "django_migrations" table which is made by djongo and I don't have control over it.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nesdis/djongo/issues/156?email_source=notifications&email_token=ALTOXN4GWYFBWIO7EY5M4KTPXP45NA5CNFSM4FJIFVWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWKCHDA#issuecomment-496247692, or mute the thread https://github.com/notifications/unsubscribe-auth/ALTOXN4QMDUKZBTXZUXDNLLPXP45NANCNFSM4FJIFVWA .
@rajat45mishra It seems I need to do something else besides downgrading. Thank you for your time!
@rajat45mishra I've found what's the problem https://github.com/nesdis/djongo/issues/274#issuecomment-496844652
Document should not be empty
Yeah, I see :)
djongo.sql2mongo.SQLDecodeError: FAILED SQL: INSERT INTO "django_migrations" ("app", "name", "applied") VALUES (%(0)s, %(1)s, %(2)s)
I got same error with version 1.2.33 in fresh installation. I downgrade to version 1.2.31 and the execution of python manage.py migrate works fine
i downgrade to 1.2.31 and sqlparse also 0.2.4 but still not works in docker
I get this error while saving a model concurrently with many threads. added a retry system and kinda works
same issues.....! downgraded to 1.2.31 and sqlparse 0.2.4.. but still same problem
Hi, I was facing the same problem here. I runned pip install --upgrade sqlparse and it not works, after it i run pip install --upgrade djongo and it works...
The weird detail is that yesterday everything was workin on my computer at company. Today I tried pulled the repo at my laptop at home and the runserver raises that exception ... The good news is that now everything is working...
I have updated it djongo pip install --upgrade djongo, and I have done the migrations python manage.py migrate --fake-initial and it has been fixed
Ok Thanks. | | Alen | | 邮箱:[email protected] | Signature is customized by Netease Mail Master On 03/13/2019 10:07, abawchen wrote: @hellonts@radzhome I guess the problem may be the version of sqlparse -- sqlparse 0.2.4 works well, but sqlparse 0.3.0 not. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
thanks bro working for me with sqlparse 0.2.4
@hellonts @radzhome I guess the problem may be the version of
sqlparse-- sqlparse 0.2.4 works well, but sqlparse 0.3.0 not.
thanks , downgrading sqlparse library from 0.3.1 to 0.2.4 fixed the issue
pip install sqlparse==0.2.4
same issues.....! downgraded to 1.2.31 and sqlparse 0.2.4.. but still same problem
make sure to downgrade django and djongo library as well. In my case i had to install pip install djongo==1.2.31 pip install Django==2.2.8 pip install sqlparse==0.2.4
same problem..if anyone solved this please reply
Had the same issue on my project. Updated Djongo with "'pip install --upgrade djongo" and it works now.
Had the same issue on my project. Updated Djongo with "'pip install --upgrade djongo" and it works now.
solved
Still same problem for me;
django === 3.0 djongo === 1.3.6 sqlparse==0.2.4