/TumbleBase

Software for the Transceiver base statio that communicates with the Tumbleweed and relays to the web server.

Primary LanguagePython

Python

Setting up virtual environment

Go into folder where you want to generate virtual environment.

python3 -m venv ./venv/

Set venv as used python environment to run your code.

source /venv/bin/activate

After setting venv as used environment install all packages from requirements.txt.

python3 -m pip install -r requirements.txt

If you get an error package requirements.txt doesn't exist you only have to add the -r flag, which you forgot before.

Install python package and generate requirements.txt

Install any new python package with the following command:

(venv) user-pc:franglomat user$ python3 -m pip install flask-restful

Generate a requirements.txt file after installing all needed pyhton packages. Don't forget to generate always a new requirements.txt file after installing new python packages. Otherwise it is not possible for every developer to set up a correct venv!

(venv) user-pc:franglomat user$ python3 -m pip freeze > requirements.txt

Flask

Important links

basic knowledge about flask_restulf
json web tokens

SqlAlchemy

Important links

basic relationships in sqlalchemy

Database

PostgreSQL Linux

install PostgreSQL on Ubuntu

After installing PostgreSQL on Ubuntu you have to follow these steps create postgres user

PostgreSQL MacOS

Uninstall old PostgreSQL
brew uninstall --force postgresql
Remove old PostgreSQL files
rm -rf /usr/local/var/postgres
Install PostgreSQL
brew install postgres
Install PostGIS

Postgis increases Postgres management capabilities by adding geospatial types and functions to enhance spatial data handled within a relational database structure.

brew install postgis
Remove old database file
rm -r /usr/local/var/postgres
Run the init command again
initdb /usr/local/var/postgres
Start PostgreSQL server
pg_ctl -D /usr/local/var/postgres/ -l logfile start
Create a new database
createdb <database>
Enable PostGIS
psql <database>
Creating extension for PostGIS
CREATE EXTENSION postgis;

PostgreSQL Create new user

Create user and grant rights to him
sudo -u postgres psql
postgres=# create database <database>;
postgres=# create user <user> with encrypted password '<password>';
postgres=# grant all privileges on database <database> to <user>;
Create vocabulary_user and grant rights to him (MacOS)
psql vocabulary
vocabulary=# create user vocabulary_user with encrypted password 'password';
vocabulary=# grant all privileges on database vocabulary to vocabulary_user;

Checking if new user has the right rights for the database.

psql -h localhost -d vocabulary -U vocabulary_user

If database opens all worked correctly, hardly always you have to enter a password for user vocabulary_user which is password in our case.