Btrieve 2
Loading...
Searching...
No Matches
Using Btrieve with Python

Using the Btrieve Python Package

Using the Btrieve Python Package on Windows

Documented below is one approach to installing the Btrieve Python Package. In this example, we will target a Windows environment. It is assumed that Zen is already installed and running.

Using the Btrieve Python Package on CentOS 9

Documented below is one approach to installing the Btrieve Python Package. In this example, we will target a CentOS 9 environment. It is assumed that Zen is already installed and running.

  • Install the GNU C++ compiler, Python and the Package Installer for Python (PIP) if not already installed.
    • Open a terminal window as a non-"root" user.
    • su -c 'yum install g++'
    • su -c 'yum install python3 python3-devel'
    • su -c 'yum install python3-pip'
  • Install the Btrieve Python Package.

Using the Btrieve Python Package on OpenSUSE 15.4

Documented below is one approach to installing the Btrieve Python Package. In this example, we will target an OpenSUSE 15.4 environment. It is assumed that Zen is already installed and running.

  • Install the GNU C++ compiler, Python and the Package Installer for Python (PIP) if not already installed.
    • Open a terminal window as a non-"root" user.
    • sudo zypper install gcc-c++
    • sudo zypper install python39 python39-devel
    • sudo zypper install python39-pip
  • Install the Btrieve Python Package.

Using the Btrieve Python Package on Ubuntu 22

Documented below is one approach to installing the Btrieve Python Package. In this example, we will target an Ubuntu 22 environment. It is assumed that Zen is already installed and running.

  • Install the GNU C++ compiler, Python and the Package Installer for Python (PIP) if not already installed.
    • Open a terminal window as a non-"root" user.
    • sudo apt install g++
    • sudo apt install python3 python3-dev
    • sudo apt install python3-pip
  • Install the Btrieve Python Package.

Using the Btrieve 2 SDK with Python

Using the Btrieve 2 SDK with Python on Windows x64

Documented below is one approach to configuring the Btrieve 2 SDK for the Python programming language. In this example, we will use Visual Studio 2015 to target a native Windows x64 environment. It is assumed that Zen is already installed and running.

  • Install SWIG and Python if not already installed.
  • Install the Btrieve 2 Windows SDK for Zen.
  • Generate, build, and install Btrieve Python.
    • Open the Visual Studio x64 Native Tools Command Prompt.
    • Change directory into the Btrieve 2 SDK directory.
    • Generate Btrieve Python.
      • c:\swigwin-3.0.12\swig.exe -cppext cpp -outcurrentdir -python -c++ -Iinclude -o btrievePython.cpp swig\btrievePython.swig
        • Note that the path to SWIG used above may differ.
    • Build Btrieve Python.
      • cl -EHsc -c -Iinclude -IC:\Python36\include btrievePython.cpp
      • link -dll win64\x86_64\btrieveCpp.lib -libpath:C:\Python36\libs -out:_btrievePython.pyd btrievePython.obj
        • Note that the path to Python used above may differ.
    • Install Btrieve Python.
      • copy btrievePython.py "c:\Program Files\Actian\Zen\bin"
      • copy _btrievePython.pyd "c:\Program Files\Actian\Zen\bin"
        • You may need elevated permissions to perform these copies.
    • Execute the Btrieve Python sample program.
      • C:\Python36\python.exe samples\btest.py 9
        • You should see the output "record: (9, 81, 3)".
        • Note that the path to Python used above may differ.
        • You may need to change the permissions of the current directory if you receive the error "AssertionError: Error: BtrieveClient.FileCreate():94:Permission error".

Using the Btrieve 2 SDK with Python on Ubuntu 20 x64

Documented below is one approach to configuring the Btrieve 2 SDK for the Python programming language. In this example, we will use the Python 3 package to target an Ubuntu 20 x64 environment. It is assumed that Zen is already installed and running.

  • Install SWIG and Python if not already installed.
    • Open a terminal window as a non-"root" user.
    • sudo apt install swig
    • sudo apt install python3 python3-dev
  • Install the Btrieve 2 Linux SDK for Zen.
  • Generate, build, and install Btrieve Python.
    • Open a terminal window as a non-"root" user.
    • Change directory into the Btrieve 2 SDK directory.
    • Generate Btrieve Python.
      • swig -cppext cpp -outcurrentdir -python -c++ -Iinclude -o btrievePython.cpp swig/btrievePython.swig
    • Build Btrieve Python.
      • g++ -c -fPIC -Iinclude -I/usr/include/python3.8 btrievePython.cpp
      • g++ -shared btrievePython.o -o _btrievePython.so -L/usr/local/actianzen/lib64 -lbtrieveCpp
        • Note that the path to Python used above may differ.
    • Install Btrieve Python.
      • sudo cp btrievePython.py /usr/local/actianzen/lib64
      • sudo cp _btrievePython.so /usr/local/actianzen/lib64
    • Execute the Btrieve Python sample program.
      • export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/usr/local/actianzen/lib64
      • python3 samples/btest.py 9
        • You should see the output "record: (9, 81, 3)".
        • Note that Python version 3 is specified.
        • You may need to change the permissions of the current directory if you receive the error "AssertionError: Error: BtrieveClient.FileCreate():94:Permission error".