I try to explain in more detail what I am trying to do.

class Country(Base, CreateUpdateMixin):
    __tablename__ = u'countries'

id = sa.Column(sa.BigInteger(), sa.Sequence('countries_id'), primary_key=True, nullable=False)
    name = sa.Column(sa.String(length=30, convert_unicode=False))
    iso2 = sa.Column(sa.String(length=2, convert_unicode=False))
    iso3 = sa.Column(sa.String(length=3, convert_unicode=False))
    telcode = sa.Column(sa.SmallInteger())

    __localize_columns__ = ['name', ]

class Country_L(Base):
__table__ = sautils.make_localize_table(Country, 'countries_l', Language, metadata)

    language = sao.relation(Language, backref='country_l')
    country = sao.relation(Country, backref='country_l')

class Country_LV(Base):
__table__ = sautils.make_localize_view(Country(), Country_L(), Language(), metadata)

Witin "make_localize_view" I need to generate a stored procedure which gets information such as columns etc from "Country" and "Country_L" , the generated code looks like this:

CREATE OR ALTER PROCEDURE countries_lp
returns (created_at DATE, updated_at TIMESTAMP, id BIGINT, name VARCHAR(30), iso2 VARCHAR(2), iso3 VARCHAR(3), telcode SMALLINT) as
    declare variable locale_name VARCHAR(30);

    begin
for select created_at, updated_at, id, name, iso2, iso3, telcode from countries
    into :created_at, :updated_at, :id, :name, :iso2, :iso3, :telcode
    do
    begin
    begin
    locale_name = Null;

    select name from countries_l
    where :id = countries_l.fk_countries_id and
countries_l.fk_languages_code5 = rdb$get_context('USER_SESSION', 'LANG_CODE')
    into :name;
    end
    if (:locale_name is not Null) then
    begin
    name = :locale_name;
    end

    suspend;
    end
    end

part of the code to generate the above is the following:

    for col in basetable.c:
        if str(col.type) == 'DATETIME':
            # hack as I can't figure out a nicer/cleaner way
            colType = 'TIMESTAMP'

basetable = Country.__table__

What I like to do is replace the check for "DATETIME" with similar/same code I assume "meta.create_all(engine)" is using to generate "create table" (can't yet figure out where/how this is all done) and ideally this should work not only for Firebird engine.

Hope this is clearer.

Thanks for looking at all this.
Werner

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

Reply via email to