Skip to main content

Oracle Object Mapping.

Project description

Oracle Object Mapping

Requirements

  • Python 3.7+

Install

pip install oracle-object-mapping

Example

Types definition

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]

Manipulate objects

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

Call function

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)

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

oracle-object-mapping-1.0.0.dev2.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file oracle-object-mapping-1.0.0.dev2.tar.gz.

File metadata

  • Download URL: oracle-object-mapping-1.0.0.dev2.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for oracle-object-mapping-1.0.0.dev2.tar.gz
Algorithm Hash digest
SHA256 72981977a7817cebd5eaba232c40f1090139757034218f3041e0b2dbe855ae55
MD5 96ca438c52ee4a345b8b88ee5b203215
BLAKE2b-256 41f6a940fb684da8f3e68ec9b01a5a8c69465b36c883bba5f81c5bcf547cbade

See more details on using hashes here.

File details

Details for the file oracle_object_mapping-1.0.0.dev2-py3-none-any.whl.

File metadata

  • Download URL: oracle_object_mapping-1.0.0.dev2-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for oracle_object_mapping-1.0.0.dev2-py3-none-any.whl
Algorithm Hash digest
SHA256 7f5750e824e69952c7120444f793a59a90c6f045f52267d22e5e3f0d1e10600e
MD5 9b313e4539a999b1ffcc45a6e084d543
BLAKE2b-256 8cecce8b442a3d50db43e8b0892a8875a409cea5c23c02591111e8a045866ee6

See more details on using hashes here.

Supported by

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