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.3-cp313-cp313-win_amd64.whl (388.0 kB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12

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

Uploaded CPython 3.11Windows x86-64

easyorm_py-1.0.3-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.3-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: easyorm_py-1.0.3-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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a1d536ab06adae866cbd20d7c9df454331ae51233e3a879e87d35813adf3c473
MD5 4547c4c28730d132073bcbbd786a7142
BLAKE2b-256 16d68d8ae8d802505dae9c03f4701ca2af4791686256325f22d05cdc982d5795

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for easyorm_py-1.0.3-cp313-cp313-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9232779a46fe831a608262d2a2f1e300d2c15c5866bffbd6093cf0f82e1aaf06
MD5 0bf4dcbecba63ddf499ee1a3bcd3b9bd
BLAKE2b-256 12f87d5913eda80efd59ffde44b9814c2eebf2f12b12fd4f846a79d7657f4682

See more details on using hashes here.

File details

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

File metadata

  • Download URL: easyorm_py-1.0.3-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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d47800f6950465f5641b3395dd1758805c71c4037d87b31421c949d622a04292
MD5 2d84c323d5e6576fc25a60e786c68df6
BLAKE2b-256 d716742252697b9ef6af6da6edec727e17e35418977e92977b3fce6930eac687

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for easyorm_py-1.0.3-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 86c6b5ad5df4cd38e51d3efc12b3cf00b5b44f37b00adfdaabdd51c1006e67b3
MD5 89a1b89690072a9e44c58e69abb73c47
BLAKE2b-256 9c9c925ce0953746ad788193583b5ae71ce9a4afa32667a83569fd6a14222adf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: easyorm_py-1.0.3-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.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f9adb1a7b1eadc0ad7702307f4988d2b7710a76bc5f6c3a59c6e1d9509699b2e
MD5 1682b959b08d66c4ceabff55c0a0ec76
BLAKE2b-256 1f5237d39c4fa5e66ca5a43b2bddc0c80c3f875bb1549d09a13fb7ef4159b790

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for easyorm_py-1.0.3-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e21af1f92903d05cc617fedc7af79360bfcc2f26794c4d87086af02bda1132d3
MD5 96c39122f116cf22827935a5c31f0a91
BLAKE2b-256 192fe2f00c9504994403646b13765ef832a11e8a05e0b02a953c68eb2cfd91b2

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