Skip to main content

Bee(BeePy) is an ORM tool with Python.

Project description

Bee

ORM Bee with Python!

Bee with Python url:
https://github.com/automvc/BeePy

Bee with Java url:
https://github.com/automvc/bee

中文介绍

点击链接可查看中文介绍

Requirement

Python 3.x(suggest 3.12+)

Feature & Function:

V1.0

1.The framework uses a unified API to operate the database;
2.Single table query, modification, addition, and deletion (SUID);
3.Developers only need to focus on the use of the SUID API, which is an object-oriented approach to the framework;
4.The entity class corresponding to the table can only use ordinary entity classes, without the need to add additional table structure information and framework related information;
5.You can specify which database to use based on the configuration information.
6.Support anti SQL injection;
7.Support native SQL;
8.The framework is responsible for managing the implementation logic of connections, transaction commit, rollback, etc;
9.The encoding complexity C (n) of ORM is O (1).

V1.1

  1. SQL keywords, supporting capitalization;
  2. Batch insert: Batch insert;
  3. Reuse the connection to improve efficiency;
  4. Add system definition exceptions

V1.3

is_sql_key_word_upper can set upper/lower in configure
Print log level characters
Improve log output
Add PreConfig to specify the location of the configuration file
Improve anomalies

V1.5

  1. add Version
  2. adjust naming

Quick Start:

Installation

To install, type:

pip install ormbee

1. set db config

1.1.can custom your db Module

in bee.json or bee.properties set dbModuleName

 {
 "dbName": "SQLite",  
 "database": "bee.db", 
 //default support: pymysql,sqlite3,cx_Oracle,psycopg2 (no need set)
 "dbModuleName":"sqlite3"
 }
#value is: MySql,SQLite,Oracle,
#MySQL config
#bee.db.dbName=MySQL
#bee.db.host =localhost
#bee.db.user =root
#bee.db.password =
#bee.db.database =bee
#bee.db.port=3306

# SQLite
bee.db.dbName=SQLite
bee.db.database =bee.db

1.2.if do not want to use the default config file(bee.json or bee.properties),

can set the db_config info yourself.

        # #mysql
        config = {  
            'dbName':'MySQL',
            'host': 'localhost',
            'user': 'root',
            'password': '',
            'database': 'bee',
            'port':3306
        }
        
        honeyConfig= HoneyConfig()
        honeyConfig.set_db_config_dict(config)

1.3.set connection directly:

        config = {  
            # 'dbName':'MySQL',
            'host': 'localhost',
            'user': 'root',
            'password': '',
            'database': 'bee',
            'port':3306
        }
        
        honeyConfig= HoneyConfig()
        honeyConfig.set_dbName("MySQL")
        
        conn = pymysql.connect(**config)
        factory=BeeFactory()
        factory.setConnection(conn)
        

2. operate DB with Bee

class Orders:
    id = None  
    name = None 
    remark = None

    #can ignore
    def __repr__(self):  
        return  str(self.__dict__)
        
class Student2:
    id = None
    name = None 
    age = None  
    remark = None
    addr = None

    def __repr__(self): 
        return  str(self.__dict__)
        
        
from bee.api import Suid

if __name__=="__main__":

    #set bee.properties/bee.json config folder, can set project root for it
    Config.config_folder_root_path="E:\\Bee-Project"

    # select record
    suid=Suid()
    orderList=suid.select(Orders()) #select all
    
    #insert    
    orders=Orders()
    orders.id=1
    orders.name="bee"
    orders.remark="test"
    
    suid=Suid()
    suid.insert(orders)
    
    #update/delete
    orders=Orders()
    orders.name="bee130"
    #For safety reasons
    #Fields that are not present in the entity will be ignored.
    orders.ext="aaa"  
    orders.id=1
    
    suid = Suid()
    n1= suid.update(orders)
    n2= suid.delete(orders)
    print(n1)
    print(n2)
    
    #batch insert
    student0=Student2()
    student0.name = "bee"
    student1=Student2()
    student1.name = "bee1"
    student1.addr=""
    student1.age=40
    entity_list=[]
    entity_list.append(student0)
    entity_list.append(student1)
    
    suidRich = SuidRich()
    insertNum = suidRich.insert_batch(entity_list)
    print(insertNum)

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

ormbee-1.5.2.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

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

ormbee-1.5.2-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

Details for the file ormbee-1.5.2.tar.gz.

File metadata

  • Download URL: ormbee-1.5.2.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for ormbee-1.5.2.tar.gz
Algorithm Hash digest
SHA256 2dcadde8e6f644481440966e4609aa75c6aa4a4056b172ed4b0f8f7fd1c7f82d
MD5 ea3ab84b6be1c26980be61c6f588d051
BLAKE2b-256 bd6f257257948636083c8fe173c0c890cdb2e8ee55d57caa651e76ffe0ac1d0f

See more details on using hashes here.

File details

Details for the file ormbee-1.5.2-py3-none-any.whl.

File metadata

  • Download URL: ormbee-1.5.2-py3-none-any.whl
  • Upload date:
  • Size: 27.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for ormbee-1.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 53e31e653d3bc81b8f7e99ee42122e9e4c10ac3aa9742b85f6951509e84deb5e
MD5 69e67c50a9da5b370a33c89921f95071
BLAKE2b-256 11f1434198deab1f3cd7db725c1052b6012e7558b20830eb8ebf4a8639272913

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