On Mon, Jun 4, 2018 at 5:28 PM, Fokko Driesprong <fo...@driesprongen.nl> wrote:
> Hi All,
>
> I'm working on making PyHive compatible with SQLAlchemy 1.2.8:
> https://github.com/Fokko/PyHive/tree/fd-fix-tests
>
> Now I run into some problems which is I can't figure out. Hopefully there is
> anyone who has more experience with this than me. The dbapi_type_map has
> been deprecated in 1.2 and now I'm unable to parse the types with raw
> queries. What does work:
>
> tbl = Table('one_row_complex', MetaData(bind=engine), autoload=True)
> rows = tbl.select().execute().fetchone()
> self.assertEqual(list(rows[0]), _ONE_ROW_COMPLEX_CONTENTS)
>
> What doesn't work:
>
> row = connection.execute('SELECT * FROM one_row_complex').fetchone()
> self.assertEqual(row, _ONE_ROW_COMPLEX_CONTENTS)

the dbape_type_map was a hack that was only used by the Oracle dialect
due to the really awkward way cx_Oracle acted with LOB objects.   It
was never used for things like date conversions and decimals - if you
use SQLite with raw SQL you will get back strings for dates and floats
for decimals too.   SQLAlchemy only applies typing behavior when you
specify it with table metadata.  In the above case, you can use
text("SELECT * FROM one_row_complex").columns(*tbl.c) to apply the
types, assuming tbl.c's columns are in the same order as they would be
from "*".

There's ways to re-introduce the ability to inject types into the
result set but this would have to be re-proposed into the new
architecture, as this was never a real "feature".



>
> I found out that the following routine isn't invoked when running the raw
> sql:
> https://github.com/Fokko/PyHive/blob/master/pyhive/sqlalchemy_hive.py#L229-L258
>
> Does anyone know how to convert the datetime and the decimal when running
> the raw SQL? I when through all the documentation and tried a lot (as you
> might see in the pull-request), but I couldn't get it to work.
>
> Please let me know,
>
> Kind regards, Fokko
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to