Skip to main content

async command line manage for fastapi

Project description

daner

Github-flavored Markdown

install

pip install daner

example

simple usage

from daner import dong

# command
# python manage.py hi --name milisp
@dong()
async def hi(name: str):
	print(name)


# command
# python manage.py hi -u milisp
# alias u=username
@dong(alias={"u": "username"})
async def create(username: str):
	print(username)


# command
# python manage.py greet --name milisp
# if you want to run a sync function
@dong(sync=True)
def greet(name):
	print(name)

create superuser

# manage.py
# createsuperuser
# $ python manage.py createsuperuser -u username -e email
from daner import dong
import databases
import getpass
import ormar
import sqlalchemy
import uvicorn

DB_URI = "sqlite:///fast.db"
database = databases.Database(DB_URI)
engine = sqlalchemy.create_engine(DB_URI)
metadata = sqlalchemy.MetaData()
metadata.create_all(engine)


class User(ormar.Model):
	class Meta(ormar.ModelMeta):
		metadata = metadata
		database = database

    id = ormar.Integer(primary_key=True)
    username = ormar.String(max_length=60, unique=True)
    password = ormar.String(max_length=2048)
    email = ormar.String(max_length=80, nullable=True, unique=True)

@dong(alias={"u": "username", "e": "email"})
async def createsuperuser(username: str, email: str = None):
    await database.connect()
	password = getpass.getpass("password: ")
    password = "hashed" + password
    await User(
        username=username,
        password=password,
        email=email,
        is_superuser=True,
    ).save()
    await database.disconnect()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

daner-0.0.3.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

daner-0.0.3-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file daner-0.0.3.tar.gz.

File metadata

  • Download URL: daner-0.0.3.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for daner-0.0.3.tar.gz
Algorithm Hash digest
SHA256 5e9f3a6cdfb1557f84c363221f1a41d064493a8074bd1871d00574c7855f9ec9
MD5 57566c10ef67e81a83ae9d18e4f2666b
BLAKE2b-256 c6392c0616bac17bd55d52b864c496e8bb3dc92148b523de5ad985013f0ccce0

See more details on using hashes here.

File details

Details for the file daner-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: daner-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for daner-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 012fa1e42f459da1fff65c5d1f496766920e600b3b01fe9823964669a2b1bf58
MD5 4a4daee435a6fbea7c1d22698f226709
BLAKE2b-256 96274529c5280d856e0dfb876c7cac6f61f481c8f421e66eb35bd6ffbf8a7dbf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page