Installation

For installing tspDB from the source files, follow the instructions depending on your system. Note that for tspDB to work you need to install PostgreSQL and plpython language pack. Details for installing them are listed below as well. We strongly recommend installing the prerequisites as shown below to avoid complications.

Mac OS

If you have downloaded tspDB before and you want to upgrade to the current version, go to here

Prerequisites (PostgreSQL and plpython)

(start from here, the later stages assume that you downloaded PostgreSQL this way):

1- Install postgreSQL 12 for Mac OS X from here

2- After the installation is done, we need to download the Language Pack. To do that, run Stack Builder (which was installed with PostgreSQL) and follow these steps:

3- Now we will make sure that PL\Python is working in PostgreSQL. To do so:

sudo vim /etc/paths

Click 'i' to go into insert mode add '/Library/PostgreSQL/12/bin' to the first line then click 'Esc' and ':x' to save and quit. Restart the terminal.

psql -U postgres
CREATE EXTENSION plpython3u;

d- If you see "CREATE EXTENSION" then the extension is working properly.

Installing tspDB

1- Download the package through cloning the repository

git clone https://github.com/AbdullahO/tspdb.git

2- Go into the package directory

cd tspdb

3- Run pip for the python Postgres uses, if you downloaded Postgres the same way described above, use the following command:

sudo /Library/edb/languagepack/v1/Python-3.7/bin/pip3 install . 

else, find the directory to the appropriate pip and run pip install .

4- Run:

cd extension_py3 && sudo make install

This step uses pg_config to find out where PostgreSQL stores its extension files, if you have another installation of Postgres, this might not work. If it does not, copy the .control and the .sql files into the share/extension directory of your PostgreSQL installation.

5- run PostgreSQL using the command (specify the appropriate user name and database as needed):

psql -U postgres

6- create tspdb extension by running

CREATE EXTENSION tspdb;

Note: if you get the error that the tspdb.control file does not exist, then step four did not run as it should. Thus do this command from inside the extension_py3 folder instead:

sudo cp -r . /Library/PostgreSQL/12/share/postgresql/extension/

and try to create the extension again.

Note: the create extension command creates the extension in the database only. You need to run that command on each database you want to use tspdb on.

Finally, test your installation here to make sure everything is working properly.

Upgrading tspDB

Caution: upgrading tspdb will remove the pindices you currently have.

1- Download the package through cloning the repository

git clone https://github.com/AbdullahO/tspdb.git

2- Go into the package directory

cd tspdb

3- Run pip for the python Postgres uses, if you downloaded Postgres the same way described above, use the following command:

sudo /Library/edb/languagepack/v1/Python-3.7/bin/pip3 install . --upgrade 

else, find the directory to the appropriate pip and run pip install . --upgrade

4- Run:

cd extension_py3 && sudo make install

5- Run PostgreSQL using the command (specify the appropriate user name and database as needed):

psql -U postgres

6- Drop and create tspdb extension by running

DROP EXTENSION tspdb CASCADE;
CREATE EXTENSION tspdb;

Windows

Prerequisites (PostgreSQL and plpython)

(start from here, the later stages assume that you downloaded PostgreSQL this way):

1- Install postgreSQL 12 from here

2- After the installation is done, we need to download the Language Pack. To do that, run Stack Builder (which was installed with PostgreSQL) and follow these steps:

3- Now we will make sure that PL\Python is working in PostgreSQL. To do so:

setx PATH "c:\edb\languagepack\v1\Python-3.7;c:\Program Files\PostgreSQL\12\bin;c:\edb\languagepack\v1\Python-3.7\Scripts;%PATH%"
setx PYTHONHOME "c:\edb\languagepack\v1\Python-3.7"
COPY "c:\edb\languagepack\v1\Python-3.7\python37.dll" "c:\Windows\System32\python37.dll" 
psql -U postgres

Note that it will ask for your password, which you have set up during the installation.

CREATE EXTENSION plpython3u;

d- If you see "CREATE EXTENSION" then this means it is working properly.

Installing tspdb

1- Download the package through cloning the repository

git clone https://github.com/AbdullahO/tspdb.git

2- Go into the package directory

cd tspdb

3- Run pip for the python Postgres uses, if you downloaded Postgres and plpython the same way described above, use the following command:

c:\edb\languagepack\v1\Python-3.7\Scripts\pip install . 

else, find the directory to the appropriate pip and run pip install .

4- Copy extension files to their appropriate postgres folder:

robocopy /s extension_py3  "c:\Program Files\PostgreSQL\12\share\extension"

This step copy the .control and the .sql files into the share/extension directory of your PostgreSQL installation. LEt's install the extension now through:

5- Run PostgreSQL using the command (specify the appropriate user name and database as needed):

psql -U postgres

6- Create tspdb extension by running

CREATE EXTENSION tspdb;

Note: the create extension command creates the extension in the database only. You need to run that command on each database you want to use tspdb on.

Finally, test your installation here to make sure everything is working properly.

Upgrading tspDB

Caution: upgrading tspdb will remove the pindices you currently have.

1- Download the package through cloning the repository

git clone https://github.com/AbdullahO/tspdb.git

2- Go into the package directory

cd tspdb

3- Run pip for the python Postgres uses, if you downloaded Postgres the same way described above, use the following command:

c:\edb\languagepack\v1\Python-3.7\Scripts\pip install .  --upgrade 

else, find the directory to the appropriate pip and run pip install . --upgrade

4- Copy extension files to their appropriate postgres folder:

robocopy /s extension_py3  "c:\Program Files\PostgreSQL\12\share\extension"

5- run PostgreSQL using the command (specify the appropriate user name and database as needed):

psql -U postgres

6- Drop and create tspdb extension by running

DROP EXTENSION tspdb CASCADE;
CREATE EXTENSION tspdb;

Ubuntu

Prerequisites (PostgreSQL and plpython)

(start from here, the later stages assume that you downloaded postgres this way):

1- Install PostgreSQL 12 along with plpython via the following steps:

sudo apt-get install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt-get install postgresql-12 postgresql-plpython3-12 

2- Now let's test the plpython3 package. Run PostgreSQL using the command (specify the appropriate user name and database as needed):

sudo -u postgres psql postgres
CREATE EXTENSION plpython3u;

If you see "CREATE EXTENSION", then it is working properly. use \q to quit postgres.

3- install pip for the python version used by postgres

cd /usr/lib/python3.6
sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo apt-get install python3-distutils
sudo python3.6 get-pip.py 
hash -d pip3

Installing tspdb

1- Download the package through cloning the repository, make sure you know where the path to the package is

git clone https://github.com/AbdullahO/tspdb.git

2- Go to the directory where Python is installed

cd /usr/lib/python3.6

3- Run pip install as follow, where \path_to_package\ is the directory where you cloned the tspdb repo:

sudo pip3 install /path_to_package/.

for example, if your package is downloaded at the user ubuntu directory, use sudo pip3 install /home/ubuntu/tspdb

4- Go to the extension_py3 directory in the package and run:

sudo cp tspdb.control /usr/share/postgresql/12/extension/tspdb.control
sudo cp tspdb--0.0.1.sql /usr/share/postgresql/12/extension/tspdb--0.0.1.sql

5- Run PostgreSQL using the command (specify the appropriate user name and database as needed):

sudo -u postgres psql postgres

6- Create tspdb extension by running

CREATE EXTENSION tspdb;

Note: the create extension command creates the extension in the database only. You need to run that command on each database you want to use tspdb on.

Finally, test your installation here to make sure everything is working properly.

Upgrading tspDB

Caution: upgrading tspdb will remove the pindices you currently have.

1- Download the package through cloning the repository

git clone https://github.com/AbdullahO/tspdb.git

2- Go to the directory where Python is installed

cd /usr/lib/python3.6

3- Run pip install as follow, where \path_to_package\ is the directory where you cloned the tspdb repo:

sudo pip3 install /path_to_package/. --upgrade

for example, if your package is downloaded at the user ubuntu directory, use sudo pip3 install /home/ubuntu/tspdb

4- Go to the extension_py3 directory in the package and run:

sudo cp tspdb.control /usr/share/postgresql/12/extension/tspdb.control
sudo cp tspdb--0.0.1.sql /usr/share/postgresql/12/extension/tspdb--0.0.1.sql

5- Run postgreSQL using the command (specify the appropriate user name and database as needed):

sudo -u postgres psql postgres

6- Drop and create tspdb extension by running

DROP EXTENSION tspdb CASCADE;
CREATE EXTENSION tspdb;

Testing tspdb

1- Test the package through running the following command in psql terminal

SELECT test_tspdb();

if you get at the last line

NOTICE:  Pindices successfully created

then tspdb should be working properly

2- Check the built pindices through

SELECT * from list_pindices();

this shows you a list of the predictive indices built in the aforementioned test. You should see three prediction indices built.

With that, you are all set to test tspDB functionalities. Start from here to get started