I am trying to insert a tuple into mysql table using python, but tuple gets converted to list in mysql table.
settings: {
'AEROSPIKE_CONN_SETTINGS' : {
'hosts': [ ('aerospike.qgraph-vpc.io', 3000) ],
'policies': {
'timeout': 3000
}
}
}
db = MySQLdb.connect(host='localhost', user='test', passwd='abcd', db='testdb')
cursor = db.cursor(MySQLdb.cursors.DictCursor)
insert_query = '''INSERT INTO test_table (`settings`) VALUES ('{}')'''.format(json.dumps(settings))
cursor.execute(insert_query)
cursor.connection.commit()
after executing the above code data gets inserted in the following format
settings:{
"AEROSPIKE_CONN_SETTINGS": {
"hosts": [["127.0.0.1", 3000]]
}
}
It should be in the following format
settings:{
"AEROSPIKE_CONN_SETTINGS": {
"hosts": [("127.0.0.1", 3000)]
}
}
what is wrong or how can I insert in the expected format. I am reading the settings from mysql table in some other python component to connect to aerospike.