SQLAlchemy: Engine object has no attribute _run_visitor
See original GitHub issueCode:
@classmethod
@asyncio.coroutine
def connect(cls):
cls.engine = yield from create_engine(host=config.MYSQL_HOST,
port=config.MYSQL_PORT,
user=config.MYSQL_USER,
password=config.MYSQL_PASSWORD,
db=config.MYSQL_DATABASE)
yield from cls.create_tables()
@classmethod
@asyncio.coroutine
def create_tables(cls):
cls.metadata = sa.MetaData()
cls.friends = sa.Table('friends', cls.metadata,
sa.Column('user_id', sa.Integer),
sa.Column('friend_id', sa.Integer))
cls.metadata.create_all(cls.engine)
cls.metadata.create_all() says:
AttributeError: 'Engine' object has no attribute '_run_visitor'
How can this be fixed?
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
SQLAlchemy AttributeError: 'AsyncEngine' object has no ...
Replace: Base.metadata.create_all(engine). with this: async def init_models(): async with engine.begin() as conn: await ...
Read more >Working with Engines and Connections — SQLAlchemy 2.0 ...
This section details direct usage of the Engine , Connection , and related objects. Its important to note that when using the SQLAlchemy...
Read more >Working with Engines and Connections — SQLAlchemy 1.3 ...
This section describes how to use transactions when working directly with Engine and Connection objects. When using the SQLAlchemy ORM, the public API...
Read more >Describing Databases with MetaData
MetaData is a container object that keeps together many different features of a database (or multiple databases) being described.
Read more >Working with Engines and Connections
This section describes how to use transactions when working directly with Engine and Connection objects. When using the SQLAlchemy ORM, the public API...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@spiralman here’s what I did:
That´s not a solution as I don´t want to write the SQL. Creating single tables by running
await MyTable.__table__.create(engine)doesn´t work either.