AttributeError: module 'peewee_async' has no attribute 'MySQLDatabase'
`import asyncio import peewee import peewee_async
database = peewee_async.MySQLDatabase('mooc',user="root", password="123456",host='127.0.0.1',port=3306)
class User(): user_id = peewee.IntegerField() user_name = peewee.CharField() nick_name = peewee.CharField() phone = peewee.IntegerField() email = peewee.CharField() password = peewee.CharField() itime = peewee.TimestampField() class Meta: database = database
objects = peewee_async.Manager(database)
database.set_allow_sync(False)
async def handler(): all_objects = await objects.execute(User.select()) for obj in all_objects: print("user_id:",obj.user_id) print("user_name:",obj.user.name)
loop = asyncio.get_event_loop() loop.run_until_complete(handler()) loop.close()`
Are you sure that you are using the latest version?
>>> import asyncio
>>> import peewee
>>> import peewee_async
>>>
>>> database = peewee_async.MySQLDatabase('mooc',user="root", password="123456",host='127.0.0.1',port=3306)
>>> peewee_async.__version__
'0.5.10'
@rudyryk
the same error.
>>> import peewee_async
>>> peewee_async.__version__
'0.6.0a'
@watsy0007 Still can't reproduce, need more details. Probably something in setup configuration somehow affetcs.
>>> import peewee
>>> peewee_async.MySQLDatabase
<class 'peewee_async.MySQLDatabase'>
>>> peewee_async.__version__
'0.6.1a'
I have checked one more time it works. Closed as outdated.