On 25/05/2011 07:41, saturngod wrote:
Now, I'm thinking about to change pyramid from PHP. I'm using advance
sql query for searching

Current mysql is using

SELECT * , IF( `Word` = 'sim', 1, IF( `Word` LIKE 'sim%', 2,
IF( `Word` LIKE '%sim', 4, 3 ) ) ) AS `sort` FROM `dblist` WHERE
`Word` LIKE '%sim%' ORDER BY `sort` , `Word`;

My guess is you can probably come up with a better way of doing this ;-)

But...

When I read pyramid, there is no code to run sql. Pyramid is using
SQLAlchemy.

Nope, Pyramid doesn't care what data storage mechanism you use.
However, if you're going to use a relational database, I'd definitely recommend SQLAlchemy. I'd also recommend http://packages.python.org/mortar_rdb/use.html, but then I'm biased...

I am not familier with ORM. Can ORM run sql ? How to run
above query in pyramid ? My current database is using MySQL.

For me, if I really needed to run that, I'd do:

session = getSession()
result = session.execute("""
SELECT * , IF( `Word` = 'sim', 1, IF( `Word` LIKE 'sim%', 2,
IF( `Word` LIKE '%sim', 4, 3 ) ) ) AS `sort` FROM `dblist` WHERE
`Word` LIKE '%sim%' ORDER BY `sort` , `Word`;
""")

But, I might also suggest having a read of:

http://www.sqlalchemy.org/docs/core/tutorial.html

cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
           - http://www.simplistix.co.uk

--
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to