【发布时间】:2019-09-17 16:57:19
【问题描述】:
我正在尝试通过 kinesis 数据流传输 rds,但它给了我这个错误:
botocore.exceptions.ClientError:发生错误 (ValidationException) 调用 PutRecord 操作时:1 检测到验证错误:值 'arn:aws:kinesis:us-west-2:xxxxxxxxx:stream/rds-temp-leads-stream' 在 “streamName”未能满足约束:成员必须满足常规 表达模式:[a-zA-Z0-9_.-]+
我能做些什么来解决这个问题?
import json
import boto3
from datetime import datetime
from pymysqlreplication import BinLogStreamReader
from pymysqlreplication.row_event import (
DeleteRowsEvent,
UpdateRowsEvent,
WriteRowsEvent,
)
class DateTimeEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, datetime):
return o.isoformat()
return json.JSONEncoder.default(self, o)
def main():
mysql = {
"host": "",
"port":,
"user": "",
"passwd": "",
"db": ""}
kinesis = boto3.client("kinesis", region_name = 'us-west-2')
stream = BinLogStreamReader(
connection_settings = mysql,
server_id=100,
blocking = True,
log_file='mysql-bin.000003',
resume_stream=True,
only_events=[DeleteRowsEvent, WriteRowsEvent, UpdateRowsEvent])
for binlogevent in stream:
for row in binlogevent.rows:
print row
event = {"schema": binlogevent.schema,
"table": binlogevent.table,
"type": type(binlogevent).__name__,
"row": row
}
kinesis.put_record(StreamName="jhgjh", Data=json.dumps(event, cls=DateTimeEncoder), PartitionKey="default")
#print json.dumps(event)
if __name__ == "__main__":
main()
【问题讨论】:
标签: python amazon-rds amazon-kinesis