#31887: from django.db.models import Avg, Max, Min, Sum In [369]: from StoreWeb.models import Product, Price In [370]: Price.objects.all().aggregate(Min('value')) ----------------------------------+------------------------------------ Reporter: Mirirous | Owner: Mirirous Type: Uncategorized | Status: assigned Component: Error reporting | Version: 3.1 Severity: Normal | Resolution: Keywords: uso de Max y Min | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 ----------------------------------+------------------------------------ Changes (by Mirirous):
* status: new => assigned * cc: Mirirous (added) * component: Uncategorized => Error reporting * owner: nobody => Mirirous * stage: Unreviewed => Accepted Old description: > OperationalError Traceback (most recent call > last) > ~/env38/StoreVirtual/lib/python3.8/site- > packages/django/db/backends/utils.py in _execute(self, sql, params, > *ignored_wrapper_args) > 85 else: > ---> 86 return self.cursor.execute(sql, params) > 87 > > ~/env38/StoreVirtual/lib/python3.8/site- > packages/django/db/backends/mysql/base.py in execute(self, query, args) > 73 # args is None means no string interpolation > ---> 74 return self.cursor.execute(query, args) > 75 except Database.OperationalError as e: > > ~/env38/StoreVirtual/lib/python3.8/site-packages/MySQLdb/cursors.py in > execute(self, query, args) > 205 assert isinstance(query, (bytes, bytearray)) > --> 206 res = self._query(query) > 207 return res > > ~/env38/StoreVirtual/lib/python3.8/site-packages/MySQLdb/cursors.py in > _query(self, q) > 318 self._result = None > --> 319 db.query(q) > 320 self._do_get_result(db) > > ~/env38/StoreVirtual/lib/python3.8/site-packages/MySQLdb/connections.py > in query(self, query) > 258 query = bytes(query) > --> 259 _mysql.connection.query(self, query) > 260 > > OperationalError: (2006, 'MySQL server has gone away') > > The above exception was the direct cause of the following exception: > > OperationalError Traceback (most recent call > last) > <ipython-input-367-52af1526b6a5> in <module> > ----> 1 Price.objects.all().aggregate(Min('value')) > > ~/env38/StoreVirtual/lib/python3.8/site- > packages/django/db/models/query.py in aggregate(self, *args, **kwargs) > 382 if not query.annotations[alias].contains_aggregate: > 383 raise TypeError("%s is not an aggregate > expression" % alias) > --> 384 return query.get_aggregation(self.db, kwargs) > 385 > 386 def count(self): > > ~/env38/StoreVirtual/lib/python3.8/site- > packages/django/db/models/sql/query.py in get_aggregation(self, using, > added_aggregate_names) > 501 outer_query.select_related = False > 502 compiler = outer_query.get_compiler(using) > --> 503 result = compiler.execute_sql(SINGLE) > 504 if result is None: > 505 result = [None] * len(outer_query.annotation_select) > > ~/env38/StoreVirtual/lib/python3.8/site- > packages/django/db/models/sql/compiler.py in execute_sql(self, > result_type, chunked_fetch, chunk_size) > 1150 cursor = self.connection.cursor() > 1151 try: > -> 1152 cursor.execute(sql, params) > 1153 except Exception: > 1154 # Might fail for server-side cursors (e.g. connection > closed) > > ~/env38/StoreVirtual/lib/python3.8/site- > packages/django/db/backends/utils.py in execute(self, sql, params) > 98 def execute(self, sql, params=None): > 99 with self.debug_sql(sql, params, > use_last_executed_query=True): > --> 100 return super().execute(sql, params) > 101 > 102 def executemany(self, sql, param_list): > > ~/env38/StoreVirtual/lib/python3.8/site- > packages/django/db/backends/utils.py in execute(self, sql, params) > 66 > 67 def execute(self, sql, params=None): > ---> 68 return self._execute_with_wrappers(sql, params, > many=False, executor=self._execute) > 69 > 70 def executemany(self, sql, param_list): > > ~/env38/StoreVirtual/lib/python3.8/site- > packages/django/db/backends/utils.py in _execute_with_wrappers(self, sql, > params, many, executor) > 75 for wrapper in reversed(self.db.execute_wrappers): > 76 executor = functools.partial(wrapper, executor) > ---> 77 return executor(sql, params, many, context) > 78 > 79 def _execute(self, sql, params, *ignored_wrapper_args): > > ~/env38/StoreVirtual/lib/python3.8/site- > packages/django/db/backends/utils.py in _execute(self, sql, params, > *ignored_wrapper_args) > 84 return self.cursor.execute(sql) > 85 else: > ---> 86 return self.cursor.execute(sql, params) > 87 > 88 def _executemany(self, sql, param_list, > *ignored_wrapper_args): > > ~/env38/StoreVirtual/lib/python3.8/site-packages/django/db/utils.py in > __exit__(self, exc_type, exc_value, traceback) > 88 if dj_exc_type not in (DataError, > IntegrityError): > 89 self.wrapper.errors_occurred = True > ---> 90 raise dj_exc_value.with_traceback(traceback) from > exc_value > 91 > 92 def __call__(self, func): > > ~/env38/StoreVirtual/lib/python3.8/site- > packages/django/db/backends/utils.py in _execute(self, sql, params, > *ignored_wrapper_args) > 84 return self.cursor.execute(sql) > 85 else: > ---> 86 return self.cursor.execute(sql, params) > 87 > 88 def _executemany(self, sql, param_list, > *ignored_wrapper_args): > > ~/env38/StoreVirtual/lib/python3.8/site- > packages/django/db/backends/mysql/base.py in execute(self, query, args) > 72 try: > 73 # args is None means no string interpolation > ---> 74 return self.cursor.execute(query, args) > 75 except Database.OperationalError as e: > 76 # Map some error codes to IntegrityError, since they > seem to be > > ~/env38/StoreVirtual/lib/python3.8/site-packages/MySQLdb/cursors.py in > execute(self, query, args) > 204 > 205 assert isinstance(query, (bytes, bytearray)) > --> 206 res = self._query(query) > 207 return res > 208 > > ~/env38/StoreVirtual/lib/python3.8/site-packages/MySQLdb/cursors.py in > _query(self, q) > 317 db = self._get_db() > 318 self._result = None > --> 319 db.query(q) > 320 self._do_get_result(db) > 321 self._post_get_result() > > ~/env38/StoreVirtual/lib/python3.8/site-packages/MySQLdb/connections.py > in query(self, query) > 257 if isinstance(query, bytearray): > 258 query = bytes(query) > --> 259 _mysql.connection.query(self, query) > 260 > 261 def _bytes_literal(self, bs): > > OperationalError: (2006, 'MySQL server has gone away') New description: -- Comment: Hola, compaƱeros tengo este error al ejecutar las siguientes lines en el shell de django from django.db.models import Avg, Max, Min, Sum In [369]: from StoreWeb.models import Product, Price In [370]: Price.objects.all().aggregate(Min('value')) EROOR OperationalError Traceback (most recent call last) ~/env38/StoreVirtual/lib/python3.8/site- packages/django/db/backends/utils.py in _execute(self, sql, params, *ignored_wrapper_args) 85 else: ---> 86 return self.cursor.execute(sql, params) 87 ~/env38/StoreVirtual/lib/python3.8/site- packages/django/db/backends/mysql/base.py in execute(self, query, args) 73 # args is None means no string interpolation ---> 74 return self.cursor.execute(query, args) 75 except Database.OperationalError as e: ~/env38/StoreVirtual/lib/python3.8/site-packages/MySQLdb/cursors.py in execute(self, query, args) 205 assert isinstance(query, (bytes, bytearray)) --> 206 res = self._query(query) 207 return res ~/env38/StoreVirtual/lib/python3.8/site-packages/MySQLdb/cursors.py in _query(self, q) 318 self._result = None --> 319 db.query(q) 320 self._do_get_result(db) ~/env38/StoreVirtual/lib/python3.8/site-packages/MySQLdb/connections.py in query(self, query) 258 query = bytes(query) --> 259 _mysql.connection.query(self, query) 260 OperationalError: (2006, 'MySQL server has gone away') The above exception was the direct cause of the following exception: OperationalError Traceback (most recent call last) <ipython-input-367-52af1526b6a5> in <module> ----> 1 Price.objects.all().aggregate(Min('value')) ~/env38/StoreVirtual/lib/python3.8/site-packages/django/db/models/query.py in aggregate(self, *args, **kwargs) 382 if not query.annotations[alias].contains_aggregate: 383 raise TypeError("%s is not an aggregate expression" % alias) --> 384 return query.get_aggregation(self.db, kwargs) 385 386 def count(self): ~/env38/StoreVirtual/lib/python3.8/site- packages/django/db/models/sql/query.py in get_aggregation(self, using, added_aggregate_names) 501 outer_query.select_related = False 502 compiler = outer_query.get_compiler(using) --> 503 result = compiler.execute_sql(SINGLE) 504 if result is None: 505 result = [None] * len(outer_query.annotation_select) ~/env38/StoreVirtual/lib/python3.8/site- packages/django/db/models/sql/compiler.py in execute_sql(self, result_type, chunked_fetch, chunk_size) 1150 cursor = self.connection.cursor() 1151 try: -> 1152 cursor.execute(sql, params) 1153 except Exception: 1154 # Might fail for server-side cursors (e.g. connection closed) ~/env38/StoreVirtual/lib/python3.8/site- packages/django/db/backends/utils.py in execute(self, sql, params) 98 def execute(self, sql, params=None): 99 with self.debug_sql(sql, params, use_last_executed_query=True): --> 100 return super().execute(sql, params) 101 102 def executemany(self, sql, param_list): ~/env38/StoreVirtual/lib/python3.8/site- packages/django/db/backends/utils.py in execute(self, sql, params) 66 67 def execute(self, sql, params=None): ---> 68 return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) 69 70 def executemany(self, sql, param_list): ~/env38/StoreVirtual/lib/python3.8/site- packages/django/db/backends/utils.py in _execute_with_wrappers(self, sql, params, many, executor) 75 for wrapper in reversed(self.db.execute_wrappers): 76 executor = functools.partial(wrapper, executor) ---> 77 return executor(sql, params, many, context) 78 79 def _execute(self, sql, params, *ignored_wrapper_args): ~/env38/StoreVirtual/lib/python3.8/site- packages/django/db/backends/utils.py in _execute(self, sql, params, *ignored_wrapper_args) 84 return self.cursor.execute(sql) 85 else: ---> 86 return self.cursor.execute(sql, params) 87 88 def _executemany(self, sql, param_list, *ignored_wrapper_args): ~/env38/StoreVirtual/lib/python3.8/site-packages/django/db/utils.py in __exit__(self, exc_type, exc_value, traceback) 88 if dj_exc_type not in (DataError, IntegrityError): 89 self.wrapper.errors_occurred = True ---> 90 raise dj_exc_value.with_traceback(traceback) from exc_value 91 92 def __call__(self, func): ~/env38/StoreVirtual/lib/python3.8/site- packages/django/db/backends/utils.py in _execute(self, sql, params, *ignored_wrapper_args) 84 return self.cursor.execute(sql) 85 else: ---> 86 return self.cursor.execute(sql, params) 87 88 def _executemany(self, sql, param_list, *ignored_wrapper_args): ~/env38/StoreVirtual/lib/python3.8/site- packages/django/db/backends/mysql/base.py in execute(self, query, args) 72 try: 73 # args is None means no string interpolation ---> 74 return self.cursor.execute(query, args) 75 except Database.OperationalError as e: 76 # Map some error codes to IntegrityError, since they seem to be ~/env38/StoreVirtual/lib/python3.8/site-packages/MySQLdb/cursors.py in execute(self, query, args) 204 205 assert isinstance(query, (bytes, bytearray)) --> 206 res = self._query(query) 207 return res 208 ~/env38/StoreVirtual/lib/python3.8/site-packages/MySQLdb/cursors.py in _query(self, q) 317 db = self._get_db() 318 self._result = None --> 319 db.query(q) 320 self._do_get_result(db) 321 self._post_get_result() ~/env38/StoreVirtual/lib/python3.8/site-packages/MySQLdb/connections.py in query(self, query) 257 if isinstance(query, bytearray): 258 query = bytes(query) --> 259 _mysql.connection.query(self, query) 260 261 def _bytes_literal(self, bs): OperationalError: (2006, 'MySQL server has gone away') -- Ticket URL: <https://code.djangoproject.com/ticket/31887#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/066.e04064190658d432e34ddf7b34f282e2%40djangoproject.com.