Re: [SQLObject] mapping DB to legacy python objects
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian B. <ia...@co...> - 2004-03-25 18:43:24
|
On Mar 25, 2004, at 2:18 AM, Charles Brandt wrote: >> You might still hit that assertion error, though I'm not quite sure >> why >> -- maybe the leading underscores. You could probably disable that >> assertion if that's the case. SQLObject should be a little smarter >> about that, and probably put quotes of some sort around the name if it >> isn't SQL-safe. > > Thanks for the responses. I agree that the leading underscores are > causing > the problems in this case. > > I checked in SQLBuilder's sqlIdentifier and found that the following > re was > causing the Assertion: > safeSQLRE = re.compile(r'^[a-zA-Z][a-zA-Z0-9_\.]*$') > > I changed that to > safeSQLRE = re.compile(r'^[a-zA-Z0-9_\.]*$') > > Which worked, but gave me some pretty strange column names: > 1/Query : CREATE TABLE sticky_sessions ( > id INT PRIMARY KEY AUTO_INCREMENT, > _sticky_sessions__remote_address VARCHAR(32), > sid VARCHAR(255) NOT NULL UNIQUE, > user_id INT, > _sticky_sessions__access_time DATETIME, > _sticky_sessions__creation_time DATETIME > ) The general rule if you get weird column names is to use the colName keyword argument. The code that generates the names is in Style.py, I believe. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |