scanning through page and replacing all instances of 00:00:00.00
Kun
neurogasm at gmail.com
Mon Apr 17 19:06:03 EDT 2006
Fredrik Lundh wrote:
> "Kun" wrote:
>
>> because in my sql database, the date is only 'date' (as in yyyy-mm-dd),
>> only when i extract it with my python-cgi does the date turn into
>> (yyyy-mm-dd 00:00:00.00), thus i figured the best way to fix this
>> problem is to parse it after the matter.
>
> you still make no sense. why not fix this in your python cgi script ?
>
> </F>
>
>
>
i have the following python-cgi which extracts data from a mysql table,
how do i parse the date so that it doesn't display the time '00:00:00.00'?
print '<h1>Query Results</h1>'
try:
db = MySQLdb.connect(host="localhost", user="xxx", passwd="xxxx",
db="xxxx")
cursor = db.cursor()
sqlstring = (select + " FROM dir" + where + order_by + limit)
print sqlstring
cursor.execute(sqlstring)
numrows = cursor.rowcount
numcols = len(cursor.description)
#print sqlstring
#print "SQL statement used:<br>" + sqlstring
print """<table border="1" cellpadding="1" cellspacing="1">"""
print "<tr>"
for col in range(0, numcols):
print "<td><b>", cursor.description[col][0], "</b></td>"
print "</tr>"
for row in range(0,numrows):
record = cursor.fetchone()
print "<tr>"
for col in range(0, numcols):
print "<td>", record[col], "</td>"
print "</tr>"
except MySQLdb.OperationalError, message:
print "Error %d:<br>%s<br><br>" % (message[0], message[1])
print "SQL statement used:<br>" + sqlstring
print "</table>"
More information about the Python-list
mailing list