DATETIME Output As 'None'
Hi, I just installed version 0.3.2 and have it working with Python 3.2.3 & MySQL 5.5.22-0Ubuntu1. Problem is, it outputs the value of DATETIME fields as 'None' and TIME fields as datetime.
-- start of script --
import mysql.connector, sys, os
from datetime import datetime
import time
tbl = "favsongs"
yr = int(input("What year? (choose 1980-2012) "))
sql = "SELECT artist,title,played FROM %s WHERE year(heard)=%s" % (tbl,str(yr))
conn = mysql.connector
c = conn.cursor()
c.execute (sql)
for row in c.fetchall():
print (row)
print(sql)
c.close()
-- end of script --
In case it helps, here's the MySQL table description:
+--
| Field | Type | Null | Key | Default | Extra |
+--
| id | bigint(100) unsigned | NO | PRI | NULL | auto_increment |
| own | tinyint(1) | NO | | 0 | |
| played | datetime | NO | | NULL | |
| station | varchar(12) | NO | | NULL | |
| released | date | NO | | NULL | |
| artist | varchar(255) | NO | | NULL | |
| title | varchar(255) | NO | | NULL | |
| notes | tinytext | NO | | NULL | |
+--
... it is possible to grab the year, month, & day separately, by using a modified SQL query like this:
SELECT artist,
But that's not quite ideal &, adding in time(played), still doesn't output the time so it's still not usable.
Oh, and I tried replacing the for loop printing with the printing in the dates.py example that comes in the example folder. It didn't fix it. I really can't see why the code would work in the dates.py but not in my code.
So, am I just missing something or is this a bug that has yet to be worked out?
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Geert JM Vanderkelen
- Solved:
- Last query:
- Last reply: