From 126f0be550539ba2dda2bb8ae508bd9e67f0973d Mon Sep 17 00:00:00 2001 From: cly Date: Sun, 22 Mar 2020 13:09:02 +0100 Subject: howto psql --- web/help.txt | 35 +++++++++++++++++++++++++++++++++++ web/website/fonctions.py | 7 +++++++ 2 files changed, 42 insertions(+) create mode 100644 web/help.txt (limited to 'web') diff --git a/web/help.txt b/web/help.txt new file mode 100644 index 0000000..fc3d38e --- /dev/null +++ b/web/help.txt @@ -0,0 +1,35 @@ +#in order to make thing right, you should check the following comments to visualize and use properly the PSQL database. + +#assuming that you installed psql prior +#https://www.postgresql.org/download/linux/debian/ + +#create the user +adduser atsuser +#use the password '123456' + +#connect as postgres +su - postgres + +#launch the psql terminal +psql + +#create the user that we use in our scripts +CREATE USER atsuser WITH PASSWORD '123456'; + +#create our databse +CREATE DATABASE atsdb; + +#grant the privileges to our user +GRANT ALL PRIVILEGES ON DATABASE atsdb to atsuser; + +#quit +Ctrl+D + +#log in as atsuser +su - atsuser + +#launch psql with our user and our database +psql -d atsdb -U atsuser + +#initialize the tables +\i /WHATEVER_PATH_YOUR_INIT_IS_IN/init-bd.sql diff --git a/web/website/fonctions.py b/web/website/fonctions.py index c968351..c1566af 100644 --- a/web/website/fonctions.py +++ b/web/website/fonctions.py @@ -1,5 +1,6 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- +import psycopg2 def baseHTML(title,body): content=(""" @@ -14,3 +15,9 @@ def baseHTML(title,body): """) return content + + +def connexionBD(): + connexion=psycopg2.connect ("host='localhost' dbname='atsdb' user='atsuser' password='123456'") + return connexion + -- cgit v1.2.3