Oracle 对象映射。
项目描述
Oracle 对象映射
要求
- Python 3.7+
安装
pip install oracle-object-mapping
例子
类型定义
import datetime
from typing import Optional
from oracle_object_mapping import objects, fields
class TABLE_VARCHARS(objects.Collection[str]):
pass
class TABLE_CLOBS(objects.Collection[str]):
package = 'LIBRARY'
database_type = fields.CLOB()
class BOOK(objects.Object):
package = 'LIBRARY'
ID: Optional[int]
TITLE: Optional[str]
AUTHORS: Optional[TABLE_VARCHARS]
DEDICATION: Optional[str] = fields.CLOB()
PAGES: Optional[TABLE_CLOBS]
PUBLISH_DATE: Optional[datetime.datetime]
操作对象
data = ["a" * x for x in range(10)]
table_a = TABLE_VARCHARS()
for x in data:
table_a.append(x)
table_b = TABLE_VARCHARS.from_data(data)
# table_a == table_b
book_a = BOOK()
book_a.TITLE = 'Hello'
book_a.AUTHORS = TABLE_VARCHARS.from_data(['Alberto', 'José'])
# ba.to_data() == {'TITLE': 'HELLO', 'AUTHORS': ['Alberto', 'José']}
data = {'TITLE': 'HELLO', 'AUTHORS': ['Alberto', 'José']}
book_b = BOOK.from_data(data)
# book_a == book_b
调用函数
from oracle_object_mapping import utils
connection: cx_Oracle.connection
name = 'LIBRARY.CREATE_BOOK'
return_type = BOOK
new_book = utils.call_function(connection, name, return_type, args=[book_a])
print(new_book.ID)
项目详情
关
oracle_object_mapping -1.0.0.dev2-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 7f5750e824e69952c7120444f793a59a90c6f045f52267d22e5e3f0d1e10600e |
|
MD5 | 9b313e4539a999b1ffcc45a6e084d543 |
|
布莱克2-256 | 8cecce8b442a3d50db43e8b0892a8875a409cea5c23c02591111e8a045866ee6 |