Skip to main content

easy_orm

Project description

example

1. load db config

from easy_orm import EasyOrmConfig
EasyOrmConfig({
    "host": "127.0.0.1",
    "port": 3306,
    "user": "root",
    "password": 123456,
    "database": "dbname",
    "mapper_xml_path": "xmlpath",
    "raw_sql": True
})

2. edit xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "">
<mapper namespace="TestMapper">

    <select id="find_data_by_ids">
        select id, username from test where id in
        <foreach collection="id_list" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
    </select>

    <select id="test_page">
        select id, username from test
    </select>

    <select id="test_where">

        select id, username from test

        <where>
            <if test="params.get('id') is not None">
                id = #{id}
            </if>
        </where>

    </select>

    <insert id="add_data">
        insert into test (nickname, username) values ('xxx', 'xxx1')
    </insert>


    <update id="update_data_by_id">
        update test set nickname = #{nickname} where id = #{id}
    </update>


    <delete id="delete_data_by_id">
        delete from test where id = #{id}
    </delete>

</mapper>

3. Extend BaseMapper and Use

# TestMapper.py
from easy_orm import BaseMapper, Page, select_one, delete


class TestMapper(BaseMapper):

    def find_data_by_ids(self, id_list: list): ...

    @select_one('select * from test where id = #{id}')
    def find_data_one(self, id: int): ...

    def test_page(self, page: Page): ...

    def test_where(self, id: int): ...

    def add_data(self): ...

    def update_data_by_id(self, nickname: str, id: int): ...

    @delete('delete from test where id = #{id}')
    def delete_data_by_id2(self, id: int): ...
    
if __name__ == '__main__':
    test = TestMapper()
    test.find_data_by_ids([1, 2, 3])

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

easyorm_py-1.0.2-cp313-cp313-win_amd64.whl (388.0 kB view details)

Uploaded CPython 3.13Windows x86-64

easyorm_py-1.0.2-cp313-cp313-manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.13

easyorm_py-1.0.2-cp312-cp312-win_amd64.whl (394.8 kB view details)

Uploaded CPython 3.12Windows x86-64

easyorm_py-1.0.2-cp312-cp312-manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.12

easyorm_py-1.0.2-cp311-cp311-win_amd64.whl (403.3 kB view details)

Uploaded CPython 3.11Windows x86-64

easyorm_py-1.0.2-cp311-cp311-manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.11

File details

Details for the file easyorm_py-1.0.2-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: easyorm_py-1.0.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 388.0 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for easyorm_py-1.0.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 6f177914e8436c7960f45a976b75df7c28c2133a8b4bbeffd3c72eae9cebf891
MD5 92501158401382badbccd9f1ff56efef
BLAKE2b-256 9e88fda25418124dd6af9aeda2015df64a3b0f9e86a36e6238015dcd0b625072

See more details on using hashes here.

File details

Details for the file easyorm_py-1.0.2-cp313-cp313-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for easyorm_py-1.0.2-cp313-cp313-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b72156539488420eb7bff975e02b111f6f0fa7bb4fde4b42000abe99a1a86752
MD5 5f330397213c905ae07e8fd06f952e24
BLAKE2b-256 777e342773871de1b9ddf7157027709890e5d15b2ca230f898e15686cbb244c6

See more details on using hashes here.

File details

Details for the file easyorm_py-1.0.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: easyorm_py-1.0.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 394.8 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for easyorm_py-1.0.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4f6e04b2bf2539e9b19f6f5057a2aa1fb7a27726bf811f1271b808a5af6f6e36
MD5 d578229fa7401b4453a4086b5e338c3d
BLAKE2b-256 aa2b4802e3e3a454d8942b064107008249cc1811c9a50ea3081ff1ddfb4ab4de

See more details on using hashes here.

File details

Details for the file easyorm_py-1.0.2-cp312-cp312-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for easyorm_py-1.0.2-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 89682e3c20062d05450d78c5eb4b589920ed4b067a880b72079485ffbe3a29ea
MD5 e91e8f4854eded55fcf89107365a042f
BLAKE2b-256 a86238d3a009e7ea960661d4991d31be6586538e02e568083683e4228755a49a

See more details on using hashes here.

File details

Details for the file easyorm_py-1.0.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: easyorm_py-1.0.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 403.3 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for easyorm_py-1.0.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3529e0d81c13c5d4a02e7277a4314dadd389f373d36a16e1bf8205b8bd39f08b
MD5 ff780f38dc0b3818707dcff87ec5e9d3
BLAKE2b-256 28387bf81da75ab27948d9ba968eb6e92a41a32127ccdb021a7406ca8400996a

See more details on using hashes here.

File details

Details for the file easyorm_py-1.0.2-cp311-cp311-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for easyorm_py-1.0.2-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b1eea8a77f322628f2981d6990026bc9206203b7e33f0f9b68433025472cadf1
MD5 1b24e41472a8371e8c50197703c7722f
BLAKE2b-256 11cb04aaf68393080ebe2f3e839bf4c09dfc28716fff479787654bd6ee8d7bde

See more details on using hashes here.

Supported by

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