python - Update the mysql table row of column type JsonBlob -


consider structure of table field 'extra' follows:

extra = sql.column(sql.jsonblob()) 

so of jsonblob type.

now need update values in field 'extra'.

when trying update 'extra' value, ends in error follows:

  file "basic_test.py", line 38     sql = "update project set extra=('{"creation_date": "%s"}') id=('%s')" % (date, tenant_id)                                                     ^ syntaxerror: invalid syntax 

code have tried follows:

    import datetime     mylist = []     today = datetime.date.today()     mylist.append(today)     date = mylist[0]      tenant_id = '1578f81703ec4bbaa1d548532c922ab9'      sql = "update project set extra='{"creation_date": "%s"}' id=('%s')" % (date, tenant_id)     cur.execute(sql) 

note:

for example, providing here same type of data used in table.

i have selected rows table , providing sample here.

('{"email": "test@example.com"}',) <type 'tuple'> 

so type of data being stored in field.

some 1 have , let me know comments.

let me know if needs more information.

thanks in advance.

i found answer myself.

extra = '{"creation_date": "%s"}' % date  sql = "update project set extra=('%s') id=('%s')" % (extra, tenant_id) 

changed query above can able see db table getting updated needed correctly.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -