Skip to content

Instantly share code, notes, and snippets.

@codemation
Created November 15, 2021 08:44
Show Gist options
  • Save codemation/f3615ee54435de636c2574a1c96222a3 to your computer and use it in GitHub Desktop.
Save codemation/f3615ee54435de636c2574a1c96222a3 to your computer and use it in GitHub Desktop.
pydbantic_app_1.py
# app.py
import asyncio
from db import setup_database
from models import Employee
async def main():
# setup db
await setup_database()
# create an Employee - save from instance
employee = Employee(salary=100000.0, is_employed=True)
await employee.save()
# create an Employee - save immedietly
employee = await Employee.create(salary=100000.0, is_employed=True)
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment