Re: [sqlalchemy] Re: list filter

2010-04-24 Thread Rami Chowdhury
On Sat, Apr 24, 2010 at 12:54, Alexander Zhabotinskiy
a.zhabotins...@gmail.com wrote:
 Another trouble (if it's possible)

 I need to get like + in_ filter.

 values = ['64', '55', '37']

 filter(Some.value.like(%:64%)), but in loop like
 filter(Some.value.like(in_([(%: + x + %) for x in values]))

As far as I know there's no way to do that other than by OR-ing the
various LIKE clauses together?



-- 
Rami Chowdhury
Never assume malice when stupidity will suffice. -- Hanlon's Razor
408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] How do we retrieve the database dialect that a specific session is using?

2010-04-24 Thread Roy Hyunjin Han
Is there any way to retrieve the database dialect that a specific
session is using?  e.g. MySQL, PostGIS, etc.

I am trying to modify Sanjiv Singh's GeoAlchemy extension so that a
person can retrieve the appropriate database procedure for a given
dialect, so that geospatial queries can be both direct (performed in a
single database call) as well as dialect-neutral.

For example, in PostGIS, getting the WKT of a geometry requires func.ST_AsText()
session.query(func.ST_AsText(Road.geom)).first()

However, in MySQL, the same procedure requires func.AsText()
session.query(func.AsText(Road.geom)).first()

I would like to be able to create a function called wkt() in both
geoalchemy/mysql.py and geoalchemy/postgis.py that enables me to the
following:
session.query(session.dialect.wkt(Road.geom)).first()

Thanks,
Roy Hyunjin Han
Modi Research Group
Earth Institute at Columbia University
http://modi.mech.columbia.edu

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Re: How do we retrieve the database dialect that a specific session is using?

2010-04-24 Thread Roy H. Han
On Apr 24, 10:00 am, Roy Hyunjin Han
starsareblueandfara...@gmail.com wrote:
 Is there any way to retrieve the database dialect that a specific
 session is using?  e.g. MySQL, PostGIS, etc.

 I am trying to modify Sanjiv Singh's GeoAlchemy extension so that a
 person can retrieve the appropriate database procedure for a given
 dialect, so that geospatial queries can be both direct (performed in a
 single database call) as well as dialect-neutral.

 For example, in PostGIS, getting the WKT of a geometry requires 
 func.ST_AsText()
 session.query(func.ST_AsText(Road.geom)).first()

 However, in MySQL, the same procedure requires func.AsText()
 session.query(func.AsText(Road.geom)).first()

 I would like to be able to create a function called wkt() in both
 geoalchemy/mysql.py and geoalchemy/postgis.py that enables me to the
 following:
 session.query(session.dialect.wkt(Road.geom)).first()


Aha found it.  Never mind.

session.connection().dialect

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Using SQLAlchemy to call stored procedures

2010-04-24 Thread Mark
Hi everyone,

I'm currently trying to convert an existing Zope web application over
to Pylons.  My DBA created a whole bunch of stored procedures for the
web application that I would really love to use in my Pylons project.
Some of the stored procedures takes a cursor as an argument.  I'm
not very DB savvy, so please forgive me if whatever I mentioned above
doesn't sound right to you.

My Question is:

Supposing I have a stored procedure in my Oracle DB called
retrieveList, how do I call that stored procedure to return me a
result set in SQLAlchemy??

I know how to do it in the normal ORM way, like:

session.query(Employee).filter(Employee.something == something).all()

Could you please teach me what to import as well?  What are the
necessary modules required for calling stored procedures in
SQLAlchemy?

Thanks a million guys!

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.