March 15th, 2013, 06:13 AM
Python + Database queries question
I am fairly new to Python and it is likely there is a very easy solution to this, but I have been trying for days now and just can't solve it so I am hoping someone here can help me.
I am trying to use Python to execute commands on a Sybase database. Running basic selects etc works fine, but I have problems executing the following command:
mount database all from '/opt/manifest_file' with listonly
If I run this manually in an sql prompt I get lots of rows as a result. When I run it through Python (using pyodbc), the command executes fine but I have problems storing the results in a variable.
If I try to fetch the results it tells me the previous SQL was not a query, which is true, but I just can't figure out how to access the results any other way.
Anyone have a good idea on how to solve this?
March 15th, 2013, 06:40 AM
Could you post your code, together with output, error messages or any other information that you think is useful.
March 15th, 2013, 07:05 AM
Originally Posted by partoj
conn = pyodbc.connect('DRIVER=SYBASE;SERVER='+args.s+';PORT='+args.p+';PWD='+args.pwd+';UID='+args.u+';app= PythonScript')
cur = conn.cursor()
cur.execute("mount database all from '/opt/manifest' with listonly")
This is my code. I don't know what to do with it from here.
cur.fetchall() does not work as it is not a query. I need to somehow be able to recieve the system messages from the database.