Мне нужно вставить весь ответ от Websocket Cilent в базу данных MySQL.К сожалению, я не нашел в интернете ничего, что могло бы мне помочь.Пока мой код:
def to_db(self):
cur = self.db.cursor()
db = self.db
while True:
data = self.ws.recv()
print(data)
sql = f"INSERT INTO `db`.`test` (`output`) VALUES ({data});"
cur.execute(sql)
db.commit()
db.close()
Когда я запускаю сценарии, я получаю следующее сообщение об ошибке:
mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"event":"info","version":2,"serverId":"e7caa4g8-7642-45f5-abc9-c9f3ad325274","pl' at line 1
Я создал свою базу данных так:
create table websocket_test
(
output json null
);