#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0

    Python + Database queries question


    Hi,

    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?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    138
    Rep Power
    2
    Could you post your code, together with output, error messages or any other information that you think is useful.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0
    Originally Posted by partoj
    Could you post your code, together with output, error messages or any other information that you think is useful.

    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.

IMN logo majestic logo threadwatch logo seochat tools logo