Skip to content

Commit

Permalink
changing drivers to support hive, presto and trino with sqlalchemy>=2…
Browse files Browse the repository at this point in the history
….0 (dropbox#448)
  • Loading branch information
nicholas-miles authored May 17, 2023
1 parent 1c1da8b commit b0206d3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
14 changes: 11 additions & 3 deletions pyhive/sqlalchemy_hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@

import re
from sqlalchemy import exc
from sqlalchemy import processors
try:
from sqlalchemy import processors
except ImportError:
# Newer versions of sqlalchemy require:
from sqlalchemy.engine import processors
from sqlalchemy import types
from sqlalchemy import util
# TODO shouldn't use mysql type
from sqlalchemy.databases import mysql
try:
from sqlalchemy.databases.mysql import MSTinyInteger
except ImportError:
# Newer versions of sqlalchemy require:
from sqlalchemy.dialects.mysql import MSTinyInteger
from sqlalchemy.engine import default
from sqlalchemy.sql import compiler
from sqlalchemy.sql.compiler import SQLCompiler
Expand Down Expand Up @@ -121,7 +129,7 @@ def __init__(self, dialect):

_type_map = {
'boolean': types.Boolean,
'tinyint': mysql.MSTinyInteger,
'tinyint': MSTinyInteger,
'smallint': types.SmallInteger,
'int': types.Integer,
'bigint': types.BigInteger,
Expand Down
8 changes: 6 additions & 2 deletions pyhive/sqlalchemy_presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
from sqlalchemy import types
from sqlalchemy import util
# TODO shouldn't use mysql type
from sqlalchemy.databases import mysql
try:
from sqlalchemy.databases.mysql import MSTinyInteger
except ImportError:
# Newer versions of sqlalchemy require:
from sqlalchemy.dialects.mysql import MSTinyInteger
from sqlalchemy.engine import default
from sqlalchemy.sql import compiler
from sqlalchemy.sql.compiler import SQLCompiler
Expand All @@ -29,7 +33,7 @@ class PrestoIdentifierPreparer(compiler.IdentifierPreparer):

_type_map = {
'boolean': types.Boolean,
'tinyint': mysql.MSTinyInteger,
'tinyint': MSTinyInteger,
'smallint': types.SmallInteger,
'integer': types.Integer,
'bigint': types.BigInteger,
Expand Down
8 changes: 6 additions & 2 deletions pyhive/sqlalchemy_trino.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
from sqlalchemy import types
from sqlalchemy import util
# TODO shouldn't use mysql type
from sqlalchemy.databases import mysql
try:
from sqlalchemy.databases.mysql import MSTinyInteger
except ImportError:
# Newer versions of sqlalchemy require:
from sqlalchemy.dialects.mysql import MSTinyInteger
from sqlalchemy.engine import default
from sqlalchemy.sql import compiler
from sqlalchemy.sql.compiler import SQLCompiler
Expand All @@ -28,7 +32,7 @@ class TrinoIdentifierPreparer(PrestoIdentifierPreparer):

_type_map = {
'boolean': types.Boolean,
'tinyint': mysql.MSTinyInteger,
'tinyint': MSTinyInteger,
'smallint': types.SmallInteger,
'integer': types.Integer,
'bigint': types.BigInteger,
Expand Down

0 comments on commit b0206d3

Please sign in to comment.