0

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.

maciejwww
  • 1,067
  • 1
  • 13
  • 26
rynrain
  • 1
  • 1
  • Hello, please share any code and error that you found on your previous attempts. Also, please refer to this guideline [how to ask a good question?](https://stackoverflow.com/help/how-to-ask) Thanks! – EnriqueBet Apr 02 '20 at 01:01

1 Answers1

0

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')

rizerphe
  • 1,340
  • 1
  • 14
  • 24
  • Please properly format code, [click here to learn how](https://wordpress.com/support/markdown-quick-reference/). – rizerphe May 09 '20 at 06:15
  • While this code may solve the question, [including an explanation](//meta.stackexchange.com/q/114762) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please [edit] your answer to add explanations and give an indication of what limitations and assumptions apply. – rizerphe May 09 '20 at 06:16