Skip to main content

iLibrary - Tools for IBM i library

Project description

iLibrary

A lightweight Python helper for working with IBM i (AS/400) libraries. It connects via ODBC (pyodbc) for DB2/SQL queries and uses Paramiko for SSH/SFTP to save and transfer library save files (SAVF).

PyPI Downloads

Overview

  • Query library metadata using QSYS2 services
  • List objects in a library (and optionally source physical files)
  • Create a save file (SAVF) for a library via SAVLIB and optionally download it
  • Remove save files
  • Simple context manager to handle DB connection lifecycle

Requirements

  • Python 3.8+
  • IBM i system access
  • IBM i Access ODBC Driver (or compatible) installed locally
  • Network access to the IBM i for ODBC and SSH/SFTP

Installation

  • From PyPI: pip install iLibrary
  • From source:
    • Clone the repo
    • Optionally create and activate a virtual environment
    • pip install -r requirements.txt
    • pip install -e .

Quickstart

from os.path import join, dirname
import os
from dotenv import load_dotenv
from iLibrary import Library

# Load ENV file and get the connection settings
dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path)
DB_DRIVER = os.environ.get("DB_DRIVER")
DB_USER = os.environ.get("DB_USER")
DB_PASSWORD = os.environ.get("DB_PASSWORD")
DB_SYSTEM = os.environ.get("DB_SYSTEM")

with Library(DB_USER, DB_PASSWORD, DB_SYSTEM, DB_DRIVER) as lib:
    print(lib.getLibraryInfo('QGPL', wantJson=True))
    print(lib.getFileInfo('QGPL'))

Save a library to SAVF and optionally download it

from os.path import dirname

with Library(DB_USER, DB_PASSWORD, DB_SYSTEM, DB_DRIVER) as lib:
    ok = lib.saveLibrary(
        library='MYLIB',
        saveFileName='MYLIBSAVE',
        description='Backup',
        localPath=dirname(__file__),
        remPath='/home/MYUSER/',
        getZip=True
    )
    print('Saved:', ok)

API overview

  • Library(db_user, db_password, db_host, db_driver)
    • enter / exit for connection lifecycle
    • iclose(): manually close the connection
  • getLibraryInfo(library: str, wantJson: bool = True) -> str | tuple
  • getFileInfo(library: str, qFiles: bool = False) -> str
  • saveLibrary(library: str, saveFileName: str, ..., getZip: bool = False, ...) -> bool
  • removeFile(library: str, saveFileName: str) -> bool

Configuration

  • Environment variables expected:
    • DB_DRIVER: e.g. {IBM i Access ODBC Driver}
    • DB_USER
    • DB_PASSWORD
    • DB_SYSTEM

Documentation

  • Installation guide: [[docs/installation.md]]
  • Usage examples: [[docs/usage.md]]
  • Full API reference: [[docs/api.md]]
  • Troubleshooting: [[docs/troubleshooting.md]]

Contributing

  • Please run tests or the sample script before submitting changes.

License

  • See the repository license file if present.

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

ilibrary-0.0.6.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

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

ilibrary-0.0.6-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file ilibrary-0.0.6.tar.gz.

File metadata

  • Download URL: ilibrary-0.0.6.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for ilibrary-0.0.6.tar.gz
Algorithm Hash digest
SHA256 e2b184a9d9c724c9bce19fc36860d0f0850f274560ed7b2f30b5647a11386054
MD5 8afd8b256a6d5ea90f3ddbcbbd6f8ed6
BLAKE2b-256 38805bb12167c2f5cdb3cb54d22b5c6febdb7e03d69fb686ce7f3ab046946245

See more details on using hashes here.

File details

Details for the file ilibrary-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: ilibrary-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for ilibrary-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1ef90e73b9cec0b902ed43d2fe7d306e28d2405836eae555d5c612d302fdd1df
MD5 905a08cdd7d6513e47cc535c4d91bafa
BLAKE2b-256 bf9ee2dd0d615e2fa60df2a16cdae91c3a014393fb8c1f3cd6b54250a385d475

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