How do I add a cylinder between two moving objects?

This question is related to this thread How to add a Line between two moving Objects with Python?

But the answer in this thread uses an edge, while I want it to be a cylinder (just like a bond connecting two atoms).

How do I extend from that answer to achieve this? Thank you.

All you need to change in the previous answer so that it would generate cylinder connectors instead of boxes, is setting the Skin modifier to smooth shading, and adding a subdivision surface modifier on top of it.

import bpy, bmesh
C = bpy.context

# Reference two cylinder objects
c1 = bpy.data.objects['C1']
c2 = bpy.data.objects['C2']

# Create new connector mesh and mesh object and link to scene
m = bpy.data.meshes.new('connector')

bm = bmesh.new()
v1 = bm.verts.new( c1.location )
v2 = bm.verts.new( c2.location )
e  = bm.edges.new([v1,v2])

bm.to_mesh(m)

o = bpy.data.objects.new( 'connector', m )

# Hook connector vertices to respective cylinders
for i, cyl in enumerate([ c1, c2 ]):
bpy.ops.object.select_all( action = 'DESELECT' )
cyl.select_set(True)
o.select_set(True)
C.view_layer.objects.active = o # Set connector as active

# Select vertex
bpy.ops.object.mode_set(mode='OBJECT')
o.data.vertices[i].select = True
bpy.ops.object.mode_set(mode='EDIT')

bpy.ops.object.mode_set(mode='OBJECT')
o.data.vertices[i].select = False

m = o.modifiers.new('Skin', 'SKIN')

## New bit starts here