sanjay's approach there is hardcoded SQL which isn't necessary with SQLAlchemy 
(though always supported as a quick approach to something).

tsvector here as a type can be implemented with UserDefinedType:

http://docs.sqlalchemy.org/en/rel_0_8/core/types.html#sqlalchemy.types.UserDefinedType

and the operators I see at 
http://www.postgresql.org/docs/8.3/static/functions-textsearch.html can be 
implemented using op():

column.op('@@@')(func.to_tsvector("some value"))

that's a little verbose, so those operations can be implemented as operators 
that are part of the tsvector type, using the techniques described at 
http://docs.sqlalchemy.org/en/rel_0_8/core/types.html#redefining-and-creating-new-operators
 .

All of this can and should be part of SQLAlchemy at some point, with external 
types like these we usually rely on volunteers, such as the recent HSTORE 
contribution.   The HSTORE module here is a great place to see an example of a 
richly functional type:  
http://hg.sqlalchemy.org/sqlalchemy/file/4abc02fbc36b/lib/sqlalchemy/dialects/postgresql/hstore.py
 



On Dec 5, 2012, at 5:37 PM, Gery . wrote:

> I was searching in google about tsvector (postgresql) implemented in 
> sqlalchemy or geoalchemy but seems to me that it's not implemented yet. After 
> searching for it in [1], it didn't matchanything. Sanjay, however, gives a 
> way to do this [2] but seems confusing to me, is it possible to use this 
> tsvector as simple as someone using types such as integer, small integer, etc 
> etc? if so, it'd be cool to know how.
> 
> Thanks,
> 
> 
> [1] 
> http://docs.sqlalchemy.org/en/rel_0_8/search.html?q=tsvector&check_keywords=yes&area=default
> [2] https://groups.google.com/forum/?fromgroups=#!topic/sqlalchemy/Dns28KksD-4
> 
> 
> 
> __________________________________________________________________________________________
> Piensa en el medio ambiente - mantenlo en la pantalla. NO lo imprimas si NO 
> es necesario.
> Think green - keep it on the screen. Do NOT print if it is NOT necessary.
> Denken Sie an die Umwelt - bewahren Sie es auf dem Bildschirm. Drucken Sie 
> NICHT, wenn es NICHT notwendig ist.
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" 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/sqlalchemy?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en.

Reply via email to