Opened 4 years ago
Last modified 4 years ago
#31887 closed Uncategorized
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')) — at Initial Version
Reported by: | Mirian Pardo | Owned by: | nobody |
---|---|---|---|
Component: | Error reporting | Version: | 3.1 |
Severity: | Normal | Keywords: | uso de Max y Min |
Cc: | Mirian Pardo | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
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>
~/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')