Skip to content

Commit

Permalink
Merge 79ce280 into ff6e7a3
Browse files Browse the repository at this point in the history
  • Loading branch information
juarezr committed Mar 24, 2021
2 parents ff6e7a3 + 79ce280 commit c1ba407
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions petl/io/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def _iter_dbapi_cursor(cursor, query, *args, **kwargs):


def _iter_sqlalchemy_engine(engine, query, *args, **kwargs):
return _iter_sqlalchemy_connection(engine.contextual_connect(), query,
return _iter_sqlalchemy_connection(engine.connect(), query,
*args, **kwargs)


Expand Down Expand Up @@ -541,7 +541,7 @@ def _todb_dbapi_cursor(table, cursor, tablename, schema=None, commit=True,
def _todb_sqlalchemy_engine(table, engine, tablename, schema=None, commit=True,
truncate=False):

_todb_sqlalchemy_connection(table, engine.contextual_connect(), tablename,
_todb_sqlalchemy_connection(table, engine.connect(), tablename,
schema=schema, commit=commit, truncate=truncate)


Expand Down
2 changes: 1 addition & 1 deletion petl/io/db_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def _execute_sqlalchemy_connection(sql, connection, commit):


def _execute_sqlalchemy_engine(sql, engine, commit):
_execute_sqlalchemy_connection(sql, engine.contextual_connect(), commit)
_execute_sqlalchemy_connection(sql, engine.connect(), commit)


def _execute_sqlalchemy_session(sql, session, commit):
Expand Down
2 changes: 1 addition & 1 deletion petl/io/db_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _is_dbapi_cursor(dbo):


def _is_sqlalchemy_engine(dbo):
return (_hasmethods(dbo, 'execute', 'contextual_connect', 'raw_connection')
return (_hasmethods(dbo, 'execute', 'connect', 'raw_connection')
and _hasprop(dbo, 'driver'))


Expand Down
8 changes: 8 additions & 0 deletions petl/test/io/test_db_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ def test_mysql():
_test_dbo(sqlalchemy_session)
sqlalchemy_session.close()

# exercise sqlalchemy engine
_setup_mysql(dbapi_connection)
sqlalchemy_engine2 = create_engine('mysql+pymysql://%s:%s@%s/%s' %
(user, password, host, database))
sqlalchemy_engine2.execute('SET SQL_MODE=ANSI_QUOTES')
_test_dbo(sqlalchemy_engine2)
sqlalchemy_engine2.dispose()

# other exercises
_test_with_schema(dbapi_connection, database)
utf8_connection = connect(host=host, user=user,
Expand Down

0 comments on commit c1ba407

Please sign in to comment.