Apache Beam SQLAlchemy PyMySql?

187 views
Skip to first unread message

mkwyche

unread,
May 18, 2019, 5:40:58 PM5/18/19
to sqlalchemy
Hi,

I'm trying to run a Beam Pipeline with SQLAlchemy. Google DataFlowRunner doesn't allow me to add MySQLdb to my pipeline running on the cloud. You can see a description of the issue here https://stackoverflow.com/questions/56202734/python-mysql-in-cloud-dataflowrunner . It seems like every time I try to create an engine the engine requires `MySQLdb`

```
Traceback (most recent call last):
  File "phy/uploader/season_stat_calculator/pipeline.py", line 10, in <module>
    from phy.uploader.season_stat_calculator.upload_season_stats_rocky import get_batters_for_season, \
  File "/Users/mkwyche/workspace/python/phy/uploader/season_stat_calculator/upload_season_stats_rocky.py", line 12, in <module>
    from phy.shared.models.season_stats.season_stats import SeasonStats
  File "/Users/mkwyche/workspace/python/phy/shared/models/__init__.py", line 19, in <module>
    _ENGINE_PHIL_DATA = get_mysql_engine(database=PHIL_DATA, echo=SQL_DEBUG)
  File "/Users/mkwyche/workspace/python/phy/shared/utils/sqlalchemy_utils.py", line 22, in get_mysql_engine
    return create_engine(db_url, echo=echo, pool_recycle=1000)
  File "/Users/mkwyche/workspace/python/.beam_env/lib/python2.7/site-packages/sqlalchemy/engine/__init__.py", line 435, in create_engine
    return strategy.create(*args, **kwargs)
  File "/Users/mkwyche/workspace/python/.beam_env/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 87, in create
    dbapi = dialect_cls.dbapi(**dbapi_args)
  File "/Users/mkwyche/workspace/python/.beam_env/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 118, in dbapi
    return __import__("MySQLdb")
ImportError: No module named MySQLdb
```

Is there anyway around needing MySQLdb when using SQLAlchemy?

Thanks,

Marcus Wyche

mkwyche

unread,
May 18, 2019, 5:44:04 PM5/18/19
to sqlalchemy
I think my issue is I just didn't have mysql+pymysql :facepalm: . Will continue to update in case others want to do this. 
Reply all
Reply to author
Forward
0 new messages