Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 15th, 2013, 05:13 AM
krasenpaskaa krasenpaskaa is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 2 krasenpaskaa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 40 m 50 sec
Reputation 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?

Reply With Quote
  #2  
Old March 15th, 2013, 05:40 AM
partoj partoj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 138 partoj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 11 h 39 m 41 sec
Reputation Power: 1
Could you post your code, together with output, error messages or any other information that you think is useful.

Reply With Quote
  #3  
Old March 15th, 2013, 06:05 AM
krasenpaskaa krasenpaskaa is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 2 krasenpaskaa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 40 m 50 sec
Reputation Power: 0
Quote:
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Python + Database queries question

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap