Re: [Tutor] html and mod_python

2006-03-23 Thread Patricia G.
Hi again!
result[0] is the value i got from the database. I tried the following piece of code and got : 
 
"TypeError: not enough arguments for format string"
   if result [0] in range(0, 101, 10):
    selected_value = result[0]
    else:
    selected_value = '-'

    tag = """
    
    %s
    -
    0%
    10%
    20%
    30%
    40%
    50%
    60%
    70%
    80%
    90%
    100%
    """ % (selected_value,selected_value)

    return tag

What did i do wrong?
Thanks,
Patty







___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] connect to a remote machine - Linux

2006-06-11 Thread Patricia G.

I'm sorry. I think I didn't explain myself well. My problem is not with the database.. The part I'm not sure how to do is connect to the remote computer.. I read somewhere that os.popen would work, but I'm not sure if that will do for me because I have to enter a passphrase and password to connect to the remote machine. 

Any ideas??
 
Thanks,

Patricia   
On 6/11/06, Roy Mac <[EMAIL PROTECTED]> wrote:
Try looking at PyDO - This provides an interface between Python and yourdatabase.  This allows you to change your database at a later time and not
have to change any Python.The excerpt below is from:http://skunkweb.sourceforge.net/PyDO2/api/html/public/pydo-module.html
PyDO (Python Data Objects) is an object-relational wrapper forrelational databases.  It provides a convenient API for retrieving andmanipulating data without constraining in any way how the data ispersisted at the RDBMS level.  Supported databases are:
  * postgresql  * mysql  * sqlite  * mssql  * oracle-Original Message-From: [EMAIL PROTECTED] [mailto:
[EMAIL PROTECTED]] On BehalfOf PatriciaSent: Sunday, June 11, 2006 4:19 PMTo: tutor@python.orgSubject: [Tutor] connect to a remote machine - LinuxHi All,
I need to connect to a remote computer on the same network to store datainto its mysql database, and I need to do this using python script.Although I've used mysql and python before, I have no idea how to access a
remote computer with Python. Also, I would have to enter a passphrase andpassword to successfully connect to it..I'd appreciate any help.Thanks!!Patricia___
Tutor maillist  -  Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] connect to a remote machine - Linux

2006-06-12 Thread Patricia G.
Thank you for the great explanation, Danny.. I was confused...
Thank you all for your help!

PatriciaOn 6/11/06, Danny Yoo <[EMAIL PROTECTED]> wrote:
> I'm sorry. I think I didn't explain myself well. My problem is not with> the database.. The part I'm not sure how to do is connect to the remote> computer..Hi Patricia,There's some confusion here.  Let's get that out in the open.
It sounds like you have a remote server.  That server provides login shellservice through ssh, and this login shell service runs on port 22, Ithink.  But if your server is running MySQL, it is very likely that it
provides network access to that MySQL database through port 3306.I think you believe that ssh login access is required to access MySQL onyour remote network server.  But this is not necessarily true: one can
access MySQL remotely without having a login shell account into themachine.  That is, rather than: Client > Login through SSH > Execute mysql clientwhich is three steps, the conventional route here is:
 Client > Connect to networked MySQL using a database driver  (MySQLdb)which is more direct.See: MySQLdb: 
http://sourceforge.net/projects/mysql-pythonas well as: http://www.devshed.com/c/a/Python/MySQL-Connectivity-With-Python/
However, this does mean that the remote MySQL server has to be set up witha separate MySQL username/password account.  That is, MySQL keeps its ownset of usernames and passwords that can be separate from the shell
logins.Also, mysqld --- the software that drives the MySQL server --- has to beenabled to work across tcp.  That requirement sounds obvious enough, butit is not the default in the MySQL server installs I've seen lately, so
double check this with your database system administrator.  In short: youcan not automatically assume that having login access to the machine willgive you MySQL database access, and visa-versa.Does this make sense so far?
> I read somewhere that os.popen would work, but I'm not sure if that will> do for meAlmost certainly no.popen is not for external database access.  People have written databasedrivers to solve this problem for you already.  It is perhaps possible to
bend popen() in such a way to access MySQL, but this will involve anamount of work to get right, and there will be a lot of ways of getting itwrong.  *grin*So I'd recommend changing this question from: "How do I get popen() to
access MySQL across a remote interface?" to a more general: "How do Iconnect to MySQL from Python?"  The link above to MySQLdb will give youthe software necessary to connect your client to a MySQL server, and the
link to the Devshed article is a tutorial on how to use it effectively.Good luck!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Mod-python

2006-06-12 Thread Patricia G.
Hi, 
When you say you that you want to send this data via Apache do youmean that the web server you are sending to is running Apache 

Yes. If you simply want to emulate a a web page with a submit button thatsends a Post you do it with code a bit like the following
import urllib, urllib2url = "" href="http://www.somesite.com/somefolder/exampl1.cgi">http://www.somesite.com/somefolder/exampl1.cgi"dict = {}dict["field1"] = "value1"
dict["field2"] = "value2"...dict["fieldn"] = "valuen"urldata = urllib.urlencode(dict)req = urllib2.Request(url)req.add_header('User-agent','Mozilla/4.0 (compatible; MSIE 
5.5; Windows NT 5.0')fd = urllib2.urlopen(req,urldata)RegardsPeter Jessop

I'll try this out. Thank you!
Patricia 
>> Hope anyone can point me to the right direction..> Thanks,
> Patricia>> ___> Tutor maillist  -  Tutor@python.org> 
http://mail.python.org/mailman/listinfo/tutor>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor