You Are Here:

Community: Developer Discussion Boards

#1 Old Using optparse - 2008-09-24, 12:34

Join Date: Aug 2008
Posts: 4
mgamberi
Offline
Registered User
I have this script:
Code:
import cx_Oracle
connection = cx_Oracle.connect("USER","PASS","ALIAS")
cursql = connection.cursor() 
cursql.execute("select SQL_TEXT,ERROR_MSG from user_resumable")
for column_1,column_2 in cursql.fetchall():
    print "Statement:", column_1," Errore: ", column_2
cursql.close()
connection.close()
I would like to pass the values of user,pass and alias when I execute this script using 3 variables, like this:
python test_connect.py name pass db

I know there is optparse. But I don't know how to use it.

I try with:
Code:
from optparse import OptionParser

parser = OptionParser()
parser.add_option('-n',"--nome",action="store")
parser.add_option('-p',"--password",action="store")
parser.add_option('-a',"--alias",action="store")
(options, args) = parser.parse_args()
Now my question:

how can I pass the arguments to the fuction:

connection = cx_Oracle.connect("USER","PASS","ALIAS")
Reply With Quote

#2 Old Re: Using optparse - 2008-09-24, 15:52

Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
gaba88
Offline
Forum Nokia Champion
never used optparse but i guess that you are simply uploading something why dont you try the code from this article.

Enjoy Pythoning
Gaba88


Gargi Das- http://gargidas.blogsot.com

Forum Nokia Python Wiki


Learn Python at http://mobapps.org/PyS60
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia