Using Btrieve 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 allow everyone to write to the current directory if you receive the error "AssertionError: Error: BtrieveClient.FileCreate():94:Permission error".
Using Btrieve with Python on Ubuntu Linux x64
Documented below is one approach to configuring the Btrieve 2 SDK for the Python programming language. In this example, we will target an Ubuntu Linux x64 environment. It is assumed that Zen is already installed and running.
-
Install SWIG and Python if not already installed.
-
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.
-
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 allow everyone to write to the current directory if you receive the error "AssertionError: Error: BtrieveClient.FileCreate():94:Permission error".