python - 用rabbitmq在数据库上写
问题描述
我是新来使用rabbitmq的。我正在做一个 poc,首先我在队列 rabbi_mq 上写入,然后我想在我的数据库中名为 product 的表上逐行写入。该表包含 3 列(id、product_name、price)
请问我该怎么做?
在我的代码下面
发件人.py
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello')
channel.basic_publish(exchange='', routing_key='hello', body= 'x12, table, 30$')
channel.basic_publish(exchange='', routing_key='hello', body= 'x13, tv, 200$')
channel.basic_publish(exchange='', routing_key='hello', body= 'x14, desk, 100$')
print('published message')
connection.close()
接收者.py
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello')
解决方案
推荐阅读
- javascript - jQuery 在悬停时从新 URL 淡入新图像而不会出现白色“闪烁”
- c++ - FLTK 设置滑块值显示区域宽度
- python - Python GRPC 如何正确重用通道
- sql - {scientistSeedError: '“[”处或附近的语法错误'}
- python - 基于第二次出现在堆栈顶部的重复元素
- presto - SQL Parser 访问者 + 元数据库 + Presto
- machine-learning - Pytorch 神经网络错误
- c# - 如何检查 SQL Server 'BACKUP DATABASE' 查询是否成功?
- arrays - 在 Julia 中以并行方式计算数组
- javascript - jQuery 查找匹配多个条件的元素