Metadata-Version: 2.4
Name: ruth-db
Version: 2022.0.0
Summary: Python database operations package
Author-email: Eyes Rutherford <ruth-tools@inbox.ru>
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: ruth-tokenizer>=2022.0.0
Requires-Dist: ruth-configurator>=2022.0.0
Requires-Dist: ruth-logger>=2022.0.0
Requires-Dist: ruth-tools[common]>=2022.0.0
Requires-Dist: ruth-tools[tables]>=2022.0.0
Requires-Dist: cx_Oracle>=8.3.0
Dynamic: license-file

# Database

This module was created to easily access different databases.
Now it supports only Oracle connection, other DBs will be added in future versions.



### Oracle

Examples:

- [ ] use:
    ```python
    from db.oracle import Oracle
    
    conn = Oracle(
        db='tns',
        username='user',
        password='pwd'
    )
    
    # query
    query = conn.sql(
        stmt='''
            select :test
            from DUAL d
        ''',
        params={
            'test': 123
        }
    )
    print(f'query: {query}')

    dml = conn.sql(
        stmt='''
            delete
            from TABLE_NAME tn
            where tn.ID > :id
        ''',
        params={
            'id': 1234
        }
    )
    print(f'dml: {dml}')
  
    plsql = conn.plsql(
        stmt='''
            begin
                :val2 := :val1 + 5;
                :val4 := :val4 + :val2;
            end;
        ''',
        params={
            'val1': 10,  # in-param
            'val4': 3  # in/out-param
        },
        params_out={
            'val2': int,  # out-param
            'val4': int  # in/out-param
        }
    )
    print(f'plsql: {plsql}')
    ```
  
