On Sep 22, 2010, at 3:06 AM, werner wrote:

> I tried with a hack to get to this, but still no luck.
> 
> I am doing:
> 
> from sqlalchemy.dialects.firebird import dialect
> ...
>    fbDialect = dialect()
> 
> ...
>        if str(col.type) == 'DATETIME':
>            print col.type.dialect_impl(fbDialect)
>            print col.type.get_dbapi_type(fbDialect)
> 
> The first one gives me "DATETIME" and the second throws this exception.
> 
> Traceback (most recent call last):
>  File "saCreateDb.py", line 5, in <module>
>    import model as db
>  File "C:\dev\aaTests\sqla\i18nFB\model.py", line 116, in <module>
>    class Country_LV(Base):
>  File "C:\dev\aaTests\sqla\i18nFB\model.py", line 117, in Country_LV
>    __table__ = sautils.make_localize_view(Country(), Country_L(), Language(), 
> metadata)
>  File "C:\dev\aaTests\sqla\i18nFB\sautils.py", line 181, in make_localize_view
>    storedProc = doCreateLocaleStoredProc(baseinst, baseTable, localeTable, 
> localeLangCol, localeFK, procName)
>  File "C:\dev\aaTests\sqla\i18nFB\sautils.py", line 31, in 
> doCreateLocaleStoredProc
>    print col.type.get_dbapi_type(fbDialect)
>  File 
> "c:\python26\lib\site-packages\sqlalchemy-0.6.4-py2.6.egg\sqlalchemy\types.py",
>  line 1191, in get_dbapi_type
>    return dbapi.DATETIME
> AttributeError: 'FBDialect_kinterbasdb' object has no attribute 'DATETIME'
> 
> What am I doing wrong here?  And is there a cleaner way of doing this, i.e. 
> get the dialect currently used instead of using a hard coded dialect.
> 
> On 20/09/2010 23:52, werner wrote:
>> I am trying to automatically generate the stored procedure I need for the 
>> localize stuff.
>> 
>> So, would like to do something like this:
>> 
>> aninst.__table__.c['created_at'].type.get_dbapi_type(dbapi) - to get e.g. 
>> TIMESTAMP for a DateTime column with Firebird SQL.


what is the piece of information you ultimately want ?   I'm not sure what you 
need the DBAPI type tokens for, unless you are working with the DBAPI's cursor 
object directly (in which case, you're working with the DBAPI 
already...dbapi.DATETIME ?  if you're generating a stored procedure you're 
already well within the realm of non-DB-agnostic).

>> Isn't there some more elegant way then doing 
>> "connection.engine.dialect.dbapi"?

there's "import kintersbasdb" ....


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