Re: [Tutor] mod_python & mysqldb problem

2006-02-23 Thread Patty

> 
> That's great news!  Does the whole thing work now, including the
> integration with mod_python? 

 
Hi Danny,
 
Yes, everything works now. The problem was the mysqldb copy I had. I also 
noticed that i had made a mistake by writting

> db.commit()

> db.close()
 
instead of: conn.commit() and conn.close()
 
Thanks again!
Patty 


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


Re: [Tutor] mod_python & mysqldb problem

2006-02-23 Thread Danny Yoo


> I downloaded the latest version of mysqldb and my code worked. btw, I
> changed it to %s instead of %d.

Hi Patty,

That's great news!  Does the whole thing work now, including the
integration with mod_python?  I'm following up and making sure that the
problem was simply the stale copy of MySQLdb.



Best of wishes!

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


Re: [Tutor] mod_python & mysqldb problem

2006-02-23 Thread Patty

Hi Danny,

I downloaded the latest version of mysqldb and my code worked. btw, I changed 
it to %s instead of %d. 

Thanks!
Patty



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


Re: [Tutor] mod_python & mysqldb problem

2006-02-23 Thread Danny Yoo


On Thu, 23 Feb 2006, Patty wrote:

> def addpercent(mp, lp):
> conn = MySQLdb.connect(host = "localhost", user = "root", passwd =
> "",db ="my_db")
> cursor = conn.cursor()
> cursor.execute ("""
> UPDATE targets
> SET mario_percent = %d, lizard_percent = %d
> WHERE target_name = 'anyname'
> """, (mp, lp))
> db.commit()
> cursor.close()
> db.close()


Hi Patty,

Does this code work outside of the context of mod_python?

There's something slightly suspicious here in the use of the '%d' format
string:  I'm not sure MySQLdb will accept it.  Let me check...

According to the DB API on parameter styles:
"""
paramstyle

String constant stating the type of parameter marker
formatting expected by the interface. Possible values are
[2]:

'qmark' Question mark style,
e.g. '...WHERE name=?'
'numeric'   Numeric, positional style,
e.g. '...WHERE name=:1'
'named' Named style,
e.g. '...WHERE name=:name'
'format'ANSI C printf format codes,
e.g. '...WHERE name=%s'
'pyformat'  Python extended format codes,
e.g. '...WHERE name=%(name)s'
"""

(http://www.python.org/peps/pep-0249.html)

So '%s' acts as a placeholder --- a parameter marker --- where MySQLdb
will later substitute parameters into.  So I'm not certain that '%d' will
work properly.


In any case, you should never get a segfault in Python code, so something
strange is happening.  Try seeing if your code works outside of mod_python
first; that'll give us at least a little more assurance that it isn't
MySQLdb that's doing funny things.  You might also want to talk with the
mod_python folks, since they'll probably be able to give you ideas on how
to get better debugging output here.


Good luck to you!

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


[Tutor] mod_python & mysqldb problem

2006-02-23 Thread Patty
Hi!

I'm new to python and MySQl and have problems trying to figure out what is wrong
with my code.  I have two files:

***control.py***

#!/usr/bin/python
import MySQLdb


def addpercent(mp, lp):
   
conn =  MySQLdb.connect(host = "localhost", user = "root", passwd = "",db
="my_db")
cursor = conn.cursor()
cursor.execute ("""
UPDATE targets
SET mario_percent = %d, lizard_percent = %d
WHERE target_name = 'anyname'
""", (mp, lp))
db.commit()
cursor.close()
db.close()


***controlcenter.html**

Ants Control Center


mario:
lizard:





**
This is what i found in error_log

 [Thu Feb 23 13:08:07 2006] [notice] mod_python: (Re)importing module
'mod_python.publisher'
[Thu Feb 23 13:08:07 2006] [notice] mod_python: (Re)importing module 'control'
with path set to '['/var/www/html/mptest']'
[Thu Feb 23 13:08:08 2006] [notice] child pid 6405 exit signal Segmentation
fault (11)


There is no reference to php in the httpd.conf file. Someone had told me that
that could be the problem.

I'd appreciate your help.   

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