Skip to content

🌊 Madtornado is a tool for generating Tornado projects for MVC.【生成tornado MVC项目模板 CLI脚手架(scaffolding)】

License

Notifications You must be signed in to change notification settings

SystemLight/madtornado4

Repository files navigation

Madtornado4

Madtornado4是一个构建MVC Tornado项目的工具。

Documentation Status Build Status

安装

pip install madtornado4
mad install <version>

用法

madtornado4通过mad命令提供构建操作,在控制台中键入mad即可获得帮助

  • mad install [version]: 指定madtornado的版本号在当前目录下初始化项目。
  • mad list: 查看所有可用的madtornado版本。
  • mad new [Template]: 在madtornado4项目下新建制定模板文件,如果不输入模板名称列出所有模板。

数据库连接

  1. 环境中需要安装aiomysql
  2. 配置launch.json
  3. 打开galaxy中的__init__.py,注册mysql服务stp.add_scoped(mysql.MysqlService).add_singleton(mysql.MysqlPoolService)
  4. 基本使用举例
class DatabaseInsertDemo(ApiGhost):
    __urls = api_router(["/database/insert"])

    @api_method
    async def get(self):
        """

        插入一条数据到表格
        访问地址:/api/database/insert

        """
        service: mysql.MysqlService = await self.obtain("MysqlService")(self.obtain("MysqlPoolService"))
        await service.execute("insert into user (name, age) values ('Lisys',20)")
        return "插入一条数据"


class DatabaseSelectDemo(ApiGhost):
    __urls = api_router(["/database/select"])

    @api_method
    async def get(self):
        """

        插入一条数据到表格
        访问地址:/api/database/select

        """
        service: mysql.MysqlService = await self.obtain("MysqlService")(self.obtain("MysqlPoolService"))
        data = await service.queryall("select * from user")
        return data

异步解决方案

领域 模块
web tornado
mysql aiomysql
sqlite3 aiosqlite
ORM peewee-async
GraphQL graphene-tornado
file aiofiles
cpu celery

文档

License

Madtornado4 uses the MIT license, see LICENSE file for the details.

About

🌊 Madtornado is a tool for generating Tornado projects for MVC.【生成tornado MVC项目模板 CLI脚手架(scaffolding)】

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published