Skip to content
New issue

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

Is this project stopped for maintenance? #164

Open
yi250 opened this issue Sep 11, 2022 · 2 comments
Open

Is this project stopped for maintenance? #164

yi250 opened this issue Sep 11, 2022 · 2 comments

Comments

@yi250
Copy link

yi250 commented Sep 11, 2022

Seems to be unavailable now,'await' outside function,I even called the code in text to run no one except to create a database

@aminalaee
Copy link
Member

Hey,
What is the issue exactly? Can you provide more info?

@iasukas
Copy link

iasukas commented Oct 3, 2022

现在好像不可用了,我甚至在文本中调用了代码来运行除了创建数据库之外没有人'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())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants