Python ORM Bee V1.5.4 众多功能更新 (上传中央库 PYPI)
Pythone ORM Bee 是基于 Python 的 ORM 工具;DeepSeek有了ORM Bee开发效率提高十倍; 让你使用 Python 开发数据库应用更简单、高效! pipinstall ormbee 简单命令即可安装 https://pypi.org/project/ormbee/ 简单易用的 ORM,开发数据库很快 主要功能 1.5.4(2025·元宵节-情人节·LTS版)3. 调整exception和select_paging4. 添加PreparedSql支持自定义SQL方式操作DB5. 更新toUpdateSQL方法6. select_by_id7. delete_by_id8. select_fun9. count10. exist11. create_table12. index_normal13. unique 往期回顾: V1.0 发布 V1.1 发布 V1.3 发布 V1.5.2 发布 安装依赖包 在命令行输入以下命令: pip install ormbee 快速开始: 1. 配置 db 连接信息 1.1.can custom your db Module in bee.json or bee.properties set dbModuleName 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', # 替换为您的 MySQL 用户名 'password': '', # 替换为您的 MySQL 密码 'database': 'bee', # 替换为您的数据库名称 'port':3306 } honeyConfig= HoneyConfig() honeyConfig.set_db_config_dict(config) 1.3.set connection directly: config = { # 'dbName':'MySQL', 'host': 'localhost', # 数据库主机 'user': 'root', # 替换为您的 MySQL 用户名 'password': '', # 替换为您的 MySQL 密码 'database': 'bee', # 替换为您的数据库名称 'port':3306 } honeyConfig= HoneyConfig() honeyConfig.set_dbName("MySQL") conn = pymysql.connect(**config) factory=BeeFactory() factory.setConnection(conn) 2. 使用 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 from bee.config import PreConfig if __name__=="__main__": #set bee.properties/bee.json config folder, can set project root for it PreConfig.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" 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) 3. 其它功能: bee.api.py 为主要的接口 Suid: 简单易用的 Select, Update, Insert, Delete 的接口; SuidRich: 功能丰富的 Suid 接口,有分页,批量插入等; PreparedSql: 自定义 sql, 可以让写自己书写性能高效的 sql 语句,接口封装更好用. Suid: simple API for Select/Update/Insert/Delete SuidRich : select_paging, insert_batch, select_first,select_by_id, delete_by_id,select_fun,count,exist,create_table,index_normal,unique PreparedSql: select, select_dict, modify, modify_dict 诚邀您的加入! 如果您还想添加什么功能,请到评论区告诉我们 (技术交流群:479080944)。 项目首页:https://gitee.com/automvc/BeePy/ https://github.com/automvc/BeePy/