schema = dj.schema('test_tables')
@schema
class Test(dj.Manual):
definition = """
pk: int
----
date=null: date
"""
Test.insert1((2, '2019-09-25'))
dj.Table._update(Test, 'date', None)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-33-b3f6114b7496> in <module>
----> 1 dj.Table._update(test.Test & 'pk=1', 'date', None)
AttributeError: module 'test' has no attribute 'Test'
In [34]: dj.Table._update(Test & 'pk=1', 'date', None)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-34-39bb5cd3e2c5> in <module>
----> 1 dj.Table._update(Test & 'pk=1', 'date', None)
~/anaconda3/lib/python3.7/site-packages/datajoint/table.py in _update(self, attrname, value)
595 placeholder=placeholder,
596 where_clause=self.where_clause)
--> 597 self.connection.query(command, args=(value, ) if value is not None else ())
598
599
~/anaconda3/lib/python3.7/site-packages/datajoint/connection.py in query(self, query, args, as_dict, suppress_warnings, reconnect)
206 cursor = self._conn.cursor(cursor=cursor_class)
207 try:
--> 208 self.__execute_query(cursor, query, args, cursor_class, suppress_warnings)
209 except errors.LostConnectionError:
210 if not reconnect:
~/anaconda3/lib/python3.7/site-packages/datajoint/connection.py in __execute_query(cursor, query, args, cursor_class, suppress_warnings)
186 # suppress all warnings arising from underlying SQL library
187 warnings.simplefilter("ignore")
--> 188 cursor.execute(query, args)
189 except client_errors as err:
190 raise translate_query_error(err, query)
~/anaconda3/lib/python3.7/site-packages/pymysql/cursors.py in execute(self, query, args)
166 pass
167
--> 168 query = self.mogrify(query, args)
169
170 result = self._query(query)
~/anaconda3/lib/python3.7/site-packages/pymysql/cursors.py in mogrify(self, query, args)
145
146 if args is not None:
--> 147 query = query % self._escape_args(args, conn)
148
149 return query
TypeError: not enough arguments for format string
---------------------------------------------------------------------------
InternalError Traceback (most recent call last)
<ipython-input-36-3407a586c925> in <module>
----> 1 dj.Table._update(Test & 'pk=1', 'date', '')
~/anaconda3/lib/python3.7/site-packages/datajoint/table.py in _update(self, attrname, value)
595 placeholder=placeholder,
596 where_clause=self.where_clause)
--> 597 self.connection.query(command, args=(value, ) if value is not None else ())
598
599
~/anaconda3/lib/python3.7/site-packages/datajoint/connection.py in query(self, query, args, as_dict, suppress_warnings, reconnect)
206 cursor = self._conn.cursor(cursor=cursor_class)
207 try:
--> 208 self.__execute_query(cursor, query, args, cursor_class, suppress_warnings)
209 except errors.LostConnectionError:
210 if not reconnect:
~/anaconda3/lib/python3.7/site-packages/datajoint/connection.py in __execute_query(cursor, query, args, cursor_class, suppress_warnings)
188 cursor.execute(query, args)
189 except client_errors as err:
--> 190 raise translate_query_error(err, query)
191
192 def query(self, query, args=(), *, as_dict=False, suppress_warnings=True, reconnect=None):
~/anaconda3/lib/python3.7/site-packages/datajoint/connection.py in translate_query_error(client_error, query)
48 if isinstance(client_error, client.err.InternalError) and client_error.args[0] == 1364:
49 return errors.MissingAttributeError(*client_error.args[1:])
---> 50 raise client_error
51
52
~/anaconda3/lib/python3.7/site-packages/datajoint/connection.py in __execute_query(cursor, query, args, cursor_class, suppress_warnings)
186 # suppress all warnings arising from underlying SQL library
187 warnings.simplefilter("ignore")
--> 188 cursor.execute(query, args)
189 except client_errors as err:
190 raise translate_query_error(err, query)
~/anaconda3/lib/python3.7/site-packages/pymysql/cursors.py in execute(self, query, args)
168 query = self.mogrify(query, args)
169
--> 170 result = self._query(query)
171 self._executed = query
172 return result
~/anaconda3/lib/python3.7/site-packages/pymysql/cursors.py in _query(self, q)
326 self._last_executed = q
327 self._clear_result()
--> 328 conn.query(q)
329 self._do_get_result()
330 return self.rowcount
~/anaconda3/lib/python3.7/site-packages/pymysql/connections.py in query(self, sql, unbuffered)
515 sql = sql.encode(self.encoding, 'surrogateescape')
516 self._execute_command(COMMAND.COM_QUERY, sql)
--> 517 self._affected_rows = self._read_query_result(unbuffered=unbuffered)
518 return self._affected_rows
519
~/anaconda3/lib/python3.7/site-packages/pymysql/connections.py in _read_query_result(self, unbuffered)
730 else:
731 result = MySQLResult(self)
--> 732 result.read()
733 self._result = result
734 if result.server_status is not None:
~/anaconda3/lib/python3.7/site-packages/pymysql/connections.py in read(self)
1073 def read(self):
1074 try:
-> 1075 first_packet = self.connection._read_packet()
1076
1077 if first_packet.is_ok_packet():
~/anaconda3/lib/python3.7/site-packages/pymysql/connections.py in _read_packet(self, packet_type)
682
683 packet = packet_type(buff, self.encoding)
--> 684 packet.check_error()
685 return packet
686
~/anaconda3/lib/python3.7/site-packages/pymysql/protocol.py in check_error(self)
218 errno = self.read_uint16()
219 if DEBUG: print("errno =", errno)
--> 220 err.raise_mysql_exception(self._data)
221
222 def dump(self):
~/anaconda3/lib/python3.7/site-packages/pymysql/err.py in raise_mysql_exception(data)
107 errval = data[3:].decode('utf-8', 'replace')
108 errorclass = error_map.get(errno, InternalError)
--> 109 raise errorclass(errno, errval)
InternalError: (1292, "Incorrect date value: '' for column `test_tables`.`test`.`date` at row 1")
gives the error:
Insert as an empty string gives: