Python module for Kafka Connect REST API
- Python (3.6)
Install using pip
...
pip install kafka-connect-python
from kafka_connect import KafkaConnect
connect = KafkaConnect(host='localhost', port=8083, scheme='http')
print(connect.api.version)
config = {
"connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
"connection.url": "jdbc:postgresql://localhost/testdb?user=testuser&password=SecurePassword!",
"key.converter": "io.confluent.connect.avro.AvroConverter",
"key.converter.schema.registry.url": "http://localhost:8081",
"value.converter": "io.confluent.connect.avro.AvroConverter",
"value.converter.schema.registry.url": "http://localhost:8081",
"table.whitelist": "sampletable",
"mode": "timestamp",
"timestamp.column.name": "lastupdated",
"topic.prefix": "test-0-"
}
connect.connectors['sample-connector'] = config
connector = connect.connectors['sample-connector']
connector.config['poll.time.ms'] = 500
list(map(lambda c: c.name, connect.connectors))
for connector in connect.connectors:
for task in connector.tasks:
task.restart()
del connect.connectors['sample-connector']