No description
Find a file
2023-06-14 20:46:42 -05:00
.github/workflows remove latest release 2023-06-14 20:46:42 -05:00
bin add bin 2023-06-08 21:06:00 -05:00
learn_sql_model wip 2023-06-14 13:43:06 -05:00
migrations wip 2023-06-10 19:01:14 -05:00
templates wip 2023-06-09 16:36:23 -05:00
tests make a game 2023-06-10 17:48:48 -05:00
.gitignore ignore database.sqlite 2023-05-22 08:10:03 -05:00
.learn-sql-model-copier-answers.yml init 2023-05-19 08:35:16 -05:00
.pyflyby wip 2023-06-11 10:46:37 -05:00
alembic.ini wip 2023-06-06 09:57:21 -05:00
CHANGELOG.md init 2023-05-19 08:35:16 -05:00
client.py wip 2023-06-14 13:43:06 -05:00
client_sender.py wip 2023-06-14 13:43:06 -05:00
docker-compose.yml wip 2023-06-06 09:57:21 -05:00
Dockerfile wip 2023-06-14 07:43:55 -05:00
dockerfile-dev wip 2023-06-06 09:57:21 -05:00
Dockerfile.dev wip 2023-06-09 16:04:58 -05:00
fly.toml wip 2023-06-14 07:43:55 -05:00
LICENSE.txt init 2023-05-19 08:35:16 -05:00
markata.toml test em 2023-05-23 08:55:35 -05:00
pyproject.toml install pyinstaller 2023-06-14 20:31:26 -05:00
README.md wip 2023-06-06 09:57:21 -05:00

Learn SQL Model

learning sql model

Development

pip install hatch
hatch shell

Development with Docker

docker compose build
docker compose up -d

To attach to the cli.

docker attach learn-sql-model-cli-1

Start the Server

learn-sql-model api run

Use the cli to manage Heros

learn-sql-model hero create

# show them
learn-sql-model hero get

# show one
learn-sql-model hero get --id 0

Use python to manage Heros

from learn_sql_model.models.hero import Hero
# create a hero
bruce = Hero(name="Batman", secret_name="Bruce Wayne")
bruce.post()
# list all heros
Hero.get()
# get one hero
Hero.get(0)

Use api to create hero

# create a curl POST request to create hero
curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"name": "Batman", "secret_name": "Bruce Wayne"}' \
  http://localhost:5000/heros

# list all heros
curl http://localhost:5000/heros
curl -X 'GET' \
  'http://localhost:5000/heros/' \
  -H 'accept: application/json'

# get one hero
curl -X 'GET' \
  'http://localhost:5000/hero/9' \
  -H 'accept: application/json'

Settings Management

config support .env, .env.dev, .env.qa, .env.prod.

ENV=dev
DATABASE_URL=sqlite:///db.sqlite
API_SERVER__PORT=8000
API_SERVER__RELOAD=False
API_SERVER__LOG_LEVEL=debug

Populating the database

learn-sql-model hero populate

Creating new modesl

learn-sql-model model create

License

learn-sql-model is distributed under the terms of the MIT license.