Skip to content

Instantly share code, notes, and snippets.

View codemation's full-sized avatar

Joshua Jamison codemation

View GitHub Profile
@codemation
codemation / pydbantic_app_4.py
Created November 15, 2021 09:08
pydbantic_app_4.py
# app.py
import asyncio
from db import setup_database
from models import Employee
async def main():
# setup db
await setup_database()
@codemation
codemation / pydbantic_app_3.py
Created November 15, 2021 09:02
pydbantic_app_3.py
# app.py
import asyncio
from db import setup_database
from models import Employee
async def main():
# setup db
await setup_database()
# app.py
import asyncio
from db import setup_database
from models import Employee
async def main():
# setup db
await setup_database()
@codemation
codemation / pydbantic_app_2-1.py
Created November 15, 2021 08:54
pydbantic_app_2-1.py
# app.py
import asyncio
from db import setup_database
from models import Employee
async def main():
# setup db
await setup_database()
@codemation
codemation / pydbantic_app_2.py
Created November 15, 2021 08:50
pydbantic_app_2.py
# app.py
import asyncio
from db import setup_database
from models import Employee
async def main():
# setup db
await setup_database()
@codemation
codemation / pydbantic_app_1.py
Created November 15, 2021 08:44
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()
@codemation
codemation / pydbantic_db_1.py
Created November 15, 2021 08:40
pydbantic_db_1.py
# db.py
from pydbantic import Database
from models import Employee
async def setup_database():
await Database.create(
'sqlite:///company.db',
tables=[Employee]
)
@codemation
codemation / pydbantic_app_0.py
Created November 15, 2021 08:23
pydbantic_app_0.py
# app.py
from models import Employee
employee = Employee(
salary=20000.0,
is_employed=True
)
print(employee)
@codemation
codemation / pydbantic_model_0.py
Last active November 15, 2021 08:21
pydbantic_model_0.py
# models.py
import uuid
from datetime import datetime
from typing import Optional
from pydbantic import DataBaseModel, PrimaryKey, Default
def time_now_str():
return datetime.now().isoformat()
def stringify_uuid():
$ cat > server_sqlite.json <<EOF
{
"DB_TYPE": "sqlite",
"DB_NAME": "auth",
"ISSUER": "EasyAuth",
"SUBJECT": "EasyAuthAuth",
"AUDIENCE": "EasyAuthApis",
"KEY_PATH": "/my_key-location",
"KEY_NAME": "test_key"
}