Getting rotation from Matrix

Hello, I’m trying to create a camera that is assigned its position and orientation from 3 point (eye, lookAt, and up). I found a cool script that creates a matrix and will assign a camera, but not in my up vector, only if I use the “X,Y,Z” designation). How can I set the camera rotation using the matrix or the up vector?

eye = Vector([0.3588833808898926, -0.4295555949211121, -0.1704823225736618])
target =  Vector([0.3996028304100037, -0.3898821771144867, -0.0804903954267502])
up =  Vector([0.4101610779762268, -0.4956580698490143, -0.1406284272670746])
      
def matrixLookat(eye, target, up):
    z = eye - target
    x = up.cross(z)
    y = z.cross(x)
    
    x.normalize()
    y.normalize()
    z.normalize()
    
    rot = Matrix()
    rot[0][0] = x[0]
    rot[0][1] = y[0]
    rot[0][2] = z[0]
    rot[0][3] = 0
    rot[1][0] = x[1]
    rot[1][1] = y[1]
    rot[1][2] = z[1]
    rot[1][3] = 0
    rot[2][0] = x[2]
    rot[2][1] = y[2]
    rot[2][2] = z[2]
    rot[2][3] = 0
    
    rot[3][0] = 0
    rot[3][1] = 0
    rot[3][2] = 0
    rot[3][3] = 1
    
    # eye not need to be minus cmp to opentk 
    # perhaps opentk has z inverse axis
    tran = Matrix.Translation(eye)
    return tran * rot

 mat = matrixLookat(eye, target, up)
bpy.ops.object.camera_add(location=eye, rotation = (math.radians(lookat), 4, up))