Here's the mysql to create my table. Create it the database "cc" for my test code.
CREATE TABLE `simple` (
`id` int(11) NOT NULL auto_increment,
`license_uri` text NOT NULL,
`search_engine` varchar(255) NOT NULL default '',
`count` bigint(20) NOT NULL default '0',
`timestamp` datetime default NULL,
`country` varchar(255) default NULL,
`language` varchar(255) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
Here's an INSERT for testing:
INSERT INTO simple (license_uri) VALUES ('http://www.nevermind.com/');
Here's a SELECT to show it got inserted:
SELECT timestamp, count, license_uri FROM simple WHERE license_uri = 'http://www.nevermind.com/';
You'll see timestamp is NULL. Okay, now let's use sqlsoup to select from the table.
Demo code:
# Set up data
from sqlalchemy.ext.sqlsoup import SqlSoup
from sqlalchemy import *
db = SqlSoup('mysql://root:@localhost/cc')
everything = db.simple.select(and_(db.simple.timestamp != None, db.simple.c.license_uri == 'http://www.nevermind.com/'))
for thing in everything:
if thing.timestamp == None:
print "BUG!"
This prints "BUG!". It should not; no rows where timestamp == None should ever be returned.
Originally reported by: Anonymous
Here's the mysql to create my table. Create it the database "cc" for my test code.
Here's an INSERT for testing:
Here's a SELECT to show it got inserted:
You'll see timestamp is NULL. Okay, now let's use sqlsoup to select from the table.
Demo code:
This prints "BUG!". It should not; no rows where timestamp == None should ever be returned.