we'll be adding a feature for this soon.  here is a non-public way to do
it for now which will work throughout 0.5:

from sqlalchemy.sql.expression import ClauseElement

class year(ClauseElement):
    __visit_name__ = 'year'
    def __init__(self, value):
        self.value = value

def _compiler_dispatch(self, compiler):
    if compiler.dialect.name == 'postgres':
        return "pg_year(%s)" % self.value
    else:
        return "sqlite_year(%s)" % self.value
year._compiler_dispatch = _compiler_dispatch


che wrote:
>
> Hi,
>
> i need to add several functions to all dialects that i'll plan to use
> in order to be fully database-independent.
> Does anybody have tips how to achieve this?
> For example i want to add function year( date) to sqlite and postgres
> dialects.
>
> TIA,
> Stefan
> >
>


--~--~---------~--~----~------------~-------~--~----~
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