Skip to content

silverback97/pysqlcipher3-for-windows

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pysqlcipher3-for-windows

With this REPO I'm trying to make life easier for all developers who need pysqlcipher3 on Windows OS.
This guide is a collection of information you learned online and from other people's guides around the world.

Contents

What is this

 Python interface to SQLCipher.

 pysqlcipher3 is an interface to the SQLite 3.x embedded relational database engine.
 It is almost fully compliant with the Python database API version 2.0. At the same time, it also exposes the unique features of SQLCipher.
 Prior to installation, libsqlcipher must already be installed on your system, with the process dependent on your operating system.

Getting Started

Requirements

Pre-Installation

  1. Install the TLC package.
  2. Install the OpenSSL package.

(refer to URLs in requirements)
NB: please install the correct architecture of your OS (x86 or x64)

 Set the system environment variable "OPENSSL_CONF":

  • for 32 bit
C:\Program Files(x86)\OpenSSL-Win32\bin\openssl.cfg
  • for 64 bit
C:\Program Files\OpenSSL-Win64\bin\openssl.cfg

Go to the folder

  • for 64 bit
"C:\Program Files\OpenSSL-Win64\lib"
  • for 32 bit
"C:\Program Files(x86)\OpenSSL-Win32\lib"

and make a copy of the following files and rename them like this:

Source Target
libcrypto.def libeay32.def
libcrypto.lib libeay32.lib
libssl.def ssleay32.def
libssl.lib ssleay32.lib

Installation

Fast Installation

In the fast-installation folder you will find an embedded-python at your disposal: use it if you don't want to have to install python on your computer.
Unzip the file you find inside and use it as if it were a normal python.

Search online how to set PYTHON_PATH and PYTHON_HOME if you want to set it as system python.

Normal Installation

In the standard-installation folder you will find a ready-made package to be able to manually install the pysqlcipher3 package in your python.

NB: The package made available has been tested with python 3.7 up to 3.9

Launch x64 Native Tools Command Prompt for VS 2022, placed in the root of sqlcipher and run these commands:

python setup.py clean  
python setup.py build_amalgamation
python setup.py install  

Slow Installation

If you want to have the latest version of pysqlcipher3 then you have to proceed to Bulding

Building for source

Building Requirements

Prepare to Build

  1. Install Visual Studio
  2. Install Visual Studio Build Tools package.

Copy the contents of the folder

  • for 64 bit
C:\Program Files\OpenSSL-Win64\include\openssl
  • for 32 bit
C:\Program Files(x86)\OpenSSL-Win32\include\openssl

  to folder C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC\14.36.32532\include

The destination folder can change depending on the version of Visual Studio you have installed and on OS architecture. However, the path is very similar.

Building

sqlcipher

Download sqlcipher (see requirements), unzip it and locate yourself in the root.
Edit the Makefile.msc file like this:

change this

TCC = $(TCC) -DSQLITE_TEMP_STORE=1

to this

TCC = $(TCC) -DSQLITE_TEMP_STORE=2 -DSQLITE_HAS_CODEC -I"C:\Program Files\OpenSSL-Win64\include"

AND

change this

# If ICU support is enabled, add the linker options for it.
#
!IF $(USE_ICU)!=0
LTLIBPATHS = $(LTLIBPATHS) /LIBPATH:$(ICULIBDIR)
LTLIBS = $(LTLIBS) $(LIBICU)
!ENDIF
# <</mark>>

to this

# If ICU support is enabled, add the linker options for it.
#
!IF $(USE_ICU)!=0
LTLIBPATHS = $(LTLIBPATHS) /LIBPATH:$(ICULIBDIR)
LTLIBS = $(LTLIBS) $(LIBICU)
!ENDIF
# <</mark>>

LTLIBPATHS = $(LTLIBPATHS) /LIBPATH:"C:\Program Files\OpenSSL-Win64\lib\VC\static"
LTLIBS = $(LTLIBS) libcrypto64MT.lib libssl64MT.lib ws2_32.lib shell32.lib advapi32.lib gdi32.lib user32.lib crypt32.lib

Launch x64 Native Tools Command Prompt for VS 2022, placed in the root of sqlcipher and run these commands:

nmake /f Makefile.msc clean
nmake /f Makefile.msc
pysqlcipher3

Download pysqlcipher3 (see requirements), unzip it and locate yourself in the root.
Create a folder inside it with the name amalgamation

copy the data from sqlcipher (it was built earlier) and place it in /pysqlcipher3/amalgamation

Download sqlite-amalgamation from https://sqlite.org/2021/sqlite-amalgamation-3340100.zip Create the sqlcipher folder inside /pysqlcipher3/src/python3.

Copy 4 files (shell.c sqlite3.c sqlite.h sqliteext.h) from sqlite-amalgamation-3340100.zip inside /pysqlcipher3/src/python3/sqlcipher

Replace the MODULE_NAME value on all files in /pysqlcipher3/src/python3.
Example:

  • FROM:
    Diagram
    TO:
    Diagram

Launch x64 Native Tools Command Prompt for VS 2022, placed in the root of sqlcipher and run these commands:

python setup.py clean  
python setup.py build_amalgamation
python setup.py install  

Releases

No releases published

Packages

No packages published