Hi,
Please share an simple idea on directly passing the orchestrator DB asset from UiPath to my python code as parameter and Decrypt the DB password on python code to access DB connection.
Hi,
Please share an simple idea on directly passing the orchestrator DB asset from UiPath to my python code as parameter and Decrypt the DB password on python code to access DB connection.
It will be better for performance to access and get all data you need direct from Orcastrator API using below URL
https://docs.uipath.com/orchestrator/reference/api-references
An samples?
@2022learncode you can find below examples on the Reset Project
also find below video playlist include all details you need
Here’s a github implementation of using Windows SecureStrings in Python.
Has to be run by the same user that owns the password though.
Plese follow the below steps in UiPath & python code as well
decrypt
function from the cryptography
library to decrypt the DB password.pyodbc
to connect to the DB using the decrypted password and other necessary connection details.Sample Code:
import pyodbc
from cryptography.fernet import Fernet
def decrypt(key, ciphertext):
f = Fernet(key)
return f.decrypt(ciphertext)
def main(db_asset):
# Retrieve the password from the DB asset and decrypt it
password = decrypt(db_asset[‘Key’], db_asset[‘Password’])
# Connect to the DB using pyodbc
connection = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};'
'SERVER=' + db_asset['Server'] + ';'
'DATABASE=' + db_asset['Database'] + ';'
'UID=' + db_asset['Username'] + ';'
'PWD=' + password)
# Do something with the connection
cursor = connection.cursor()
cursor.execute("SELECT * FROM my_table")
rows = cursor.fetchall()
for row in rows:
print(row)
Regards,
Kaviyarasu N