How can I connect to a sql/mp or sql/mx database on Nonstop using python.?

527 Views Asked by At

I am trying to connect to a sql/mx database using python on OSS. However, it does not seem to be working. I would appreciate any solutions be it both to connect externally or from Python on OSS.

1

There are 1 best solutions below

2
On

Use pyodbc,

#!/usr/bin/python3

import pyodbc
pyodbc.pooling = False   

usr = "xxx"
pas = "xxx"
conn = pyodbc.connect('DRIVER={NonStop ODBC/MX 3.6};SERVER=TCP:127.0.0.1/18000;UID=%s;PWD=%s' % (usr,pas))

cursor = conn.cursor()

rows = cursor.execute("select * from cat.db.table for browse access")
for row in rows:
  print( row)
print (cursor.description)

Try above, it will work. I prefer implicit connection, explore if something below will work and let me knpw conn = pyodbc.connect('TRUSTED_CONNECTION=YES;DRIVER={NonStop ODBC/MX 3.6};SERVER=TCP:127.0.0.1/18201;DATABASE=XYZ')