Python, Mysql, insert NULL

2005-10-05 Thread Python_it
Python 2.4
MySQL-python.exe-1.2.0.win32-py2.4.zip

How can I insert a NULL value in a table (MySQL-database).
I can't set a var to NULL? Or is there a other possibility?
My var must be variable string or NULL.
Becaus i have a if statement:
if 
  cursor.execute(".insert NULL ..")
if 
  cursor.execute(".insert "string" ..")

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python, Mysql, insert NULL

2005-10-05 Thread Python_it
I know how to insert values in a database.
That's not my problem!
My problem is how i insert NULL values in de mysql-database.
None is een object in Python and NULL not.
None is not converted to NULL?
Table shows None and not NULL!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python, Mysql, insert NULL

2005-10-06 Thread Python_it
Thanks for the many replies!
The problem was that is use '%s', i have to use %s and then my problem
is solved.

-- 
http://mail.python.org/mailman/listinfo/python-list


mod_python

2005-10-11 Thread Python_it
Today I was busy to install mod_python.

I have put the line

LoadModule python_module libexec/mod_python.so

into the httpd.conf file.
It Works!
Apache load mod_python /3.2.2.b Python2.4

But my problem is where I have to place te following code in de
httpd.conf?


AddHandler mod_python .py
PythonHandler mptest
PythonDebug On


Because al the tutorials write this. But where?

If I try to put the code some where,
apache give the following message by testing the configure:
Multiple  arguments not (yet) supported
But what i have to change or replace.

I test with the next file:

C:\Program Files\Apache Group\Apache2\htdocs\project\
mptest.py

from mod_python import apache

def handler(req):
   req.content_type = 'text/plain'
   req.send_http_header()
   req.write('mptest.py\n')
   return apache.OK

Is this code enough for testing?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mod_python

2005-10-11 Thread Python_it
Thanks for your replay.
I put the handler code at the end of the file.
No error!
But if I go to my localhost\project\mptest.py
The code of my function appears.
I solve this by put the following code in the confige file:


AllowOverride FileInfo


-- 
http://mail.python.org/mailman/listinfo/python-list


mod_python mptest.py works publisher not

2005-10-12 Thread Python_it
I'm going to work with mod_python.

I install mod_python 3.2.2b for python 2.4.

If i test my install with
mptest.py
see this link:
http://www.modpython.org/live/mod_python-3.2.2b/doc-html/modpython.html
IT WORKS!

But if i try this:


AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On


http://www.modpython.org/live/mod_python-3.2.2b/doc-html/tut-pub.html

It don't work!

I Get the following message:

Mod_python error: "PythonHandler mod_python.publisher"

Traceback (most recent call last):

  File "C:\Program
Files\Python24\Lib\site-packages\mod_python\apache.py", line 299, in
HandlerDispatch
result = object(req)

  File "C:\Program
Files\Python24\Lib\site-packages\mod_python\publisher.py", line 204, in
handler
module = page_cache[req]

  File "C:\Program
Files\Python24\Lib\site-packages\mod_python\cache.py", line 77, in
__getitem__
return self._checkitem(name)[2]

  File "C:\Program
Files\Python24\Lib\site-packages\mod_python\cache.py", line 119, in
_checkitem
value = self.build(key, name, opened, entry)

  File "C:\Program
Files\Python24\Lib\site-packages\mod_python\publisher.py", line 77, in
build
return ModuleCache.build(self, key, req, opened, entry)

  File "C:\Program
Files\Python24\Lib\site-packages\mod_python\cache.py", line 367, in
build
module = new.module(re_not_word.sub('_',key))

AttributeError: 'module' object has no attribute 'module'


HELP?

-- 
http://mail.python.org/mailman/listinfo/python-list


cgi python

2005-10-13 Thread Python_it
I going to use the cgi-handler (mod_python):

http://www.modpython.org/live/mod_python-3.2.2b/doc-html/hand-cgi.html


If I test a simply py script it works

code:
===
print "Content-type: text/html\n"
print """


TEST


"""


But if I test a py script with cgi comments (import cgi):

Part of the code

import cgi

#get HTTP query parameters
query = cgi.FieldStorage()

#Get the selected year and month
selectedYear = int(query["year"].value)
selectedMonth = int(query["x"].value) + 1

#Get the monthly revenue
monthlyRevenue = float(query["value"].value)


I get the following error:

errormessage:
==
Mod_python error: "PythonHandler mod_python.cgihandler"

Traceback (most recent call last):

  File "C:\Program
Files\Python24\Lib\site-packages\mod_python\apache.py", line 299, in
HandlerDispatch
result = object(req)

  File "C:\Program
Files\Python24\Lib\site-packages\mod_python\cgihandler.py", line 96, in
handler
imp.load_module(module_name, fd, path, desc)

  File "C:/Program Files/Apache
Group/Apache2/htdocs/clue/modules/templates\clickpie.py", line 9, in ?
selectedYear = int(query["year"].value)

  File "C:\Program Files\Python24\Lib\cgi.py", line 559, in __getitem__
raise KeyError, key

KeyError: 'year'


Who can help me?

-- 
http://mail.python.org/mailman/listinfo/python-list


mysql connection

2005-11-18 Thread Python_it
How can I close more cursors at the END of my page,
after execute some scripts/functions.

example:
I use one DB connection and 5 cursor actions.

How can I close these connections/actions at the END of my page?


cursor.close() ==> 5 times??
db.close()

-- 
http://mail.python.org/mailman/listinfo/python-list