Changes between Initial Version and Version 1 of Ticket #31887


Ignore:
Timestamp:
Aug 14, 2020, 9:31:32 AM (4 years ago)
Author:
Mirian Pardo
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')

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #31887

    • Property Cc Mirian Pardo added
    • Property Component UncategorizedError reporting
    • Property Owner changed from nobody to Mirian Pardo
    • Property Triage Stage UnreviewedAccepted
    • Property Status newassigned
  • Ticket #31887 – Description

    initial v1  
    1 OperationalError                          Traceback (most recent call last)
    2 ~/env38/StoreVirtual/lib/python3.8/site-packages/django/db/backends/utils.py in _execute(self, sql, params, *ignored_wrapper_args)
    3      85             else:
    4 ---> 86                 return self.cursor.execute(sql, params)
    5      87
    6 
    7 ~/env38/StoreVirtual/lib/python3.8/site-packages/django/db/backends/mysql/base.py in execute(self, query, args)
    8      73             # args is None means no string interpolation
    9 ---> 74             return self.cursor.execute(query, args)
    10      75         except Database.OperationalError as e:
    11 
    12 ~/env38/StoreVirtual/lib/python3.8/site-packages/MySQLdb/cursors.py in execute(self, query, args)
    13     205         assert isinstance(query, (bytes, bytearray))
    14 --> 206         res = self._query(query)
    15     207         return res
    16 
    17 ~/env38/StoreVirtual/lib/python3.8/site-packages/MySQLdb/cursors.py in _query(self, q)
    18     318         self._result = None
    19 --> 319         db.query(q)
    20     320         self._do_get_result(db)
    21 
    22 ~/env38/StoreVirtual/lib/python3.8/site-packages/MySQLdb/connections.py in query(self, query)
    23     258             query = bytes(query)
    24 --> 259         _mysql.connection.query(self, query)
    25     260
    26 
    27 OperationalError: (2006, 'MySQL server has gone away')
    28 
    29 The above exception was the direct cause of the following exception:
    30 
    31 OperationalError                          Traceback (most recent call last)
    32 <ipython-input-367-52af1526b6a5> in <module>
    33 ----> 1 Price.objects.all().aggregate(Min('value'))
    34 
    35 ~/env38/StoreVirtual/lib/python3.8/site-packages/django/db/models/query.py in aggregate(self, *args, **kwargs)
    36     382             if not query.annotations[alias].contains_aggregate:
    37     383                 raise TypeError("%s is not an aggregate expression" % alias)
    38 --> 384         return query.get_aggregation(self.db, kwargs)
    39     385
    40     386     def count(self):
    41 
    42 ~/env38/StoreVirtual/lib/python3.8/site-packages/django/db/models/sql/query.py in get_aggregation(self, using, added_aggregate_names)
    43     501         outer_query.select_related = False
    44     502         compiler = outer_query.get_compiler(using)
    45 --> 503         result = compiler.execute_sql(SINGLE)
    46     504         if result is None:
    47     505             result = [None] * len(outer_query.annotation_select)
    48 
    49 ~/env38/StoreVirtual/lib/python3.8/site-packages/django/db/models/sql/compiler.py in execute_sql(self, result_type, chunked_fetch, chunk_size)
    50    1150             cursor = self.connection.cursor()
    51    1151         try:
    52 -> 1152             cursor.execute(sql, params)
    53    1153         except Exception:
    54    1154             # Might fail for server-side cursors (e.g. connection closed)
    55 
    56 ~/env38/StoreVirtual/lib/python3.8/site-packages/django/db/backends/utils.py in execute(self, sql, params)
    57      98     def execute(self, sql, params=None):
    58      99         with self.debug_sql(sql, params, use_last_executed_query=True):
    59 --> 100             return super().execute(sql, params)
    60     101
    61     102     def executemany(self, sql, param_list):
    62 
    63 ~/env38/StoreVirtual/lib/python3.8/site-packages/django/db/backends/utils.py in execute(self, sql, params)
    64      66
    65      67     def execute(self, sql, params=None):
    66 ---> 68         return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
    67      69
    68      70     def executemany(self, sql, param_list):
    69 
    70 ~/env38/StoreVirtual/lib/python3.8/site-packages/django/db/backends/utils.py in _execute_with_wrappers(self, sql, params, many, executor)
    71      75         for wrapper in reversed(self.db.execute_wrappers):
    72      76             executor = functools.partial(wrapper, executor)
    73 ---> 77         return executor(sql, params, many, context)
    74      78
    75      79     def _execute(self, sql, params, *ignored_wrapper_args):
    76 
    77 ~/env38/StoreVirtual/lib/python3.8/site-packages/django/db/backends/utils.py in _execute(self, sql, params, *ignored_wrapper_args)
    78      84                 return self.cursor.execute(sql)
    79      85             else:
    80 ---> 86                 return self.cursor.execute(sql, params)
    81      87
    82      88     def _executemany(self, sql, param_list, *ignored_wrapper_args):
    83 
    84 ~/env38/StoreVirtual/lib/python3.8/site-packages/django/db/utils.py in __exit__(self, exc_type, exc_value, traceback)
    85      88                 if dj_exc_type not in (DataError, IntegrityError):
    86      89                     self.wrapper.errors_occurred = True
    87 ---> 90                 raise dj_exc_value.with_traceback(traceback) from exc_value
    88      91
    89      92     def __call__(self, func):
    90 
    91 ~/env38/StoreVirtual/lib/python3.8/site-packages/django/db/backends/utils.py in _execute(self, sql, params, *ignored_wrapper_args)
    92      84                 return self.cursor.execute(sql)
    93      85             else:
    94 ---> 86                 return self.cursor.execute(sql, params)
    95      87
    96      88     def _executemany(self, sql, param_list, *ignored_wrapper_args):
    97 
    98 ~/env38/StoreVirtual/lib/python3.8/site-packages/django/db/backends/mysql/base.py in execute(self, query, args)
    99      72         try:
    100      73             # args is None means no string interpolation
    101 ---> 74             return self.cursor.execute(query, args)
    102      75         except Database.OperationalError as e:
    103      76             # Map some error codes to IntegrityError, since they seem to be
    104 
    105 ~/env38/StoreVirtual/lib/python3.8/site-packages/MySQLdb/cursors.py in execute(self, query, args)
    106     204
    107     205         assert isinstance(query, (bytes, bytearray))
    108 --> 206         res = self._query(query)
    109     207         return res
    110     208
    111 
    112 ~/env38/StoreVirtual/lib/python3.8/site-packages/MySQLdb/cursors.py in _query(self, q)
    113     317         db = self._get_db()
    114     318         self._result = None
    115 --> 319         db.query(q)
    116     320         self._do_get_result(db)
    117     321         self._post_get_result()
    118 
    119 ~/env38/StoreVirtual/lib/python3.8/site-packages/MySQLdb/connections.py in query(self, query)
    120     257         if isinstance(query, bytearray):
    121     258             query = bytes(query)
    122 --> 259         _mysql.connection.query(self, query)
    123     260
    124     261     def _bytes_literal(self, bs):
    125 
    126 OperationalError: (2006, 'MySQL server has gone away')
Back to Top