Saturday, September 12, 2020

Setting up Sqlite3 Python embedded database and Sqlitebrowser on CentOS 8.2

**************************************************************
UPDATE 09/25/2020
The most recent updates to CentOS 8.2 Repos makes qt5-devel unavailable,  so setup Qt5 has been updated correspondingly
Please, don't be hesitant to use "--skip broken" it might be required in case if you installed from complete DVD version (USB stick) and keep system in up to date shape. When install has been done from minimal DVD install qt5-* and afterwards $ dnf group install "Server with GUI" . See also Setting up Sqlite3 Python embedded database and Sqlitebrowser on Virtual Box CentOS 8.2 VM
**************************************************************
First instatll "Development Tools", rebuild Python 3.8.5
after installation sqlite-devel. Afterwards build sqlitebrowser from source rather then install via snap, qt5-* packages would have to be installed for successful build on CentOS 8.2.

$ sudo dnf groupinstall "Development Tools" -y
$ sudo dnf install sqlite-devel

Rebuild Python

$cd ; $ cd ./Python-3.8.5
$ ./configure —enable-optimizations
$ sudo make altinstall

Prepare to build sqlitebrowser which wouldn't
have any issues with Qt vs the one provided via snap

$ sudo dnf install qt5-* or $ sudo dnf install qt5-* --skip-broken
$ git clone https://github.com/sqlitebrowser/sqlitebrowser
$ cd sqlitebrowser
$ cmake -Wno-dev .
$ make
$ sudo make install



[boris@Server82 sqlitebrowser]$ file sqlitebrowser
sqlitebrowser: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=94852e47e12ccdf516d4a1194083745885911192, not stripped

Make sure
[boris@Server82 ~]$ python3.8
Python 3.8.5 (default, Sep 11 2020, 12:09:30)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>>


Now follow for instance sqlite3 – Embedded Relational Database and see that basic DDL && DML operations work with no problems via Python API . However, Encrypting would require Python 2.7. Just one sample :-

[boris@Server82 DB]$ python3.8 sqlite3_create_function.py
Original values:
(1, 'write about select')
(2, 'write about random')
(3, 'write about sqlite3')
(4, 'finish reviewing markup')
(5, 'revise chapter intros')
(6, 'subtitle')

Encrypting...
Encrypting 'write about select'
Traceback (most recent call last):
  File "sqlite3_create_function.py", line 29, in <module>
    cursor.execute(query)
sqlite3.OperationalError: user-defined function raised exception

[boris@Server82 DB]$ python2.7
bash: python2.7: command not found...
Install package 'python2' to provide command 'python2.7'? [N/y] y

 * Waiting in queue... 
 * Loading list of packages.... 
The following packages have to be installed:
 python2-2.7.17-1.module_el8.2.0+381+9a5b3c3b.x86_64 An interpreted, interactive, object-oriented programming language
 python2-libs-2.7.17-1.module_el8.2.0+381+9a5b3c3b.x86_64 Runtime libraries for Python 2
 python2-pip-9.0.3-16.module_el8.2.0+381+9a5b3c3b.noarch A tool for installing and managing Python 2 packages
 python2-pip-wheel-9.0.3-16.module_el8.2.0+381+9a5b3c3b.noarch The pip wheel
 python2-setuptools-39.0.1-11.module_el8.2.0+381+9a5b3c3b.noarch Easily build and distribute Python packages
 python2-setuptools-wheel-39.0.1-11.module_el8.2.0+381+9a5b3c3b.noarch The setuptools wheel
Proceed with changes? [N/y] y

 * Waiting in queue... 
 * Waiting for authentication... 
 * Waiting in queue... 
 * Downloading packages... 
 * Requesting data... 
 * Testing changes... 
 * Installing packages... 

[boris@Server82 DB]$ python2.7 sqlite3_create_function.py
Original values:
(1, u'write about select')
(2, u'write about random')
(3, u'write about sqlite3')
(4, u'finish reviewing markup')
(5, u'revise chapter intros')
(6, u'subtitle')

Encrypting...
Encrypting u'write about select'
Encrypting u'write about random'
Encrypting u'write about sqlite3'
Encrypting u'finish reviewing markup'
Encrypting u'revise chapter intros'
Encrypting u'subtitle'

Raw encrypted values:
(1, u'jevgr nobhg fryrpg')
(2, u'jevgr nobhg enaqbz')
(3, u'jevgr nobhg fdyvgr3')
(4, u'svavfu erivrjvat znexhc')
(5, u'erivfr puncgre vagebf')
(6, u'fhogvgyr')

Decrypting in query...
Decrypting u'jevgr nobhg fryrpg'
Decrypting u'jevgr nobhg enaqbz'
Decrypting u'jevgr nobhg fdyvgr3'
Decrypting u'svavfu erivrjvat znexhc'
Decrypting u'erivfr puncgre vagebf'
Decrypting u'fhogvgyr'
(1, u'write about select')
(2, u'write about random')
(3, u'write about sqlite3')
(4, u'finish reviewing markup')
(5, u'revise chapter intros')
(6, u'subtitle')



   Switching to Xorg when logging in
 

    Verification sqlite database version
  


No comments:

Post a Comment