We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Seems to be unavailable now,'await' outside function,I even called the code in text to run no one except to create a database
'await' outside function,
The text was updated successfully, but these errors were encountered:
Hey, What is the issue exactly? Can you provide more info?
Sorry, something went wrong.
现在好像不可用了,我甚至在文本中调用了代码来运行除了创建数据库之外没有人'await' outside function,
Did you copy the sample code directly?
Functions that contain await need to be used in async functions
Like this
import asyncio import databases import orm database = databases.Database("sqlite:///db.sqlite") models = orm.ModelRegistry(database=database) class Note(orm.Model): tablename = "notes" registry = models fields = { "id": orm.Integer(primary_key=True), "text": orm.String(max_length=100), "completed": orm.Boolean(default=False), } async def main(): # Create the tables await models.create_all() await Note.objects.create(text="Buy the groceries.", completed=False) note = await Note.objects.get(id=1) print(note) # Note(id=1) if __name__ == '__main__': asyncio.run(main())
No branches or pull requests
Seems to be unavailable now,
'await' outside function,
I even called the code in text to run no one except to create a databaseThe text was updated successfully, but these errors were encountered: