Adding mariadb table creation
continuous-integration/drone/push Build is failing Details

main
Félix MIELCAREK 11 months ago
parent e879a2e33e
commit e7e678868a

@ -4,13 +4,13 @@ name: BB_PIPELINE
steps: steps:
- name: deploy-container-pgsql - name: deploy-container-db
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
environment: environment:
IMAGENAME: mariadb:10 IMAGENAME: mariadb:10
CONTAINERNAME: bigbrotherdb CONTAINERNAME: bigbrotherdb
COMMAND: create COMMAND: create
# OVERWRITE: false OVERWRITE: false
PRIVATE: true PRIVATE: true
CODEFIRST_CLIENTDRONE_ENV_MARIADB_ROOT_PASSWORD: CODEFIRST_CLIENTDRONE_ENV_MARIADB_ROOT_PASSWORD:
from_secret: db_root_password from_secret: db_root_password
@ -21,19 +21,19 @@ steps:
CODEFIRST_CLIENTDRONE_ENV_MARIADB_PASSWORD: CODEFIRST_CLIENTDRONE_ENV_MARIADB_PASSWORD:
from_secret: db_password from_secret: db_password
# - name: create-bigbrother-database - name: create-bigbrother-database
# image: python:latest image: python:latest
# commands: commands:
# - cd database/ - cd database/
# - pip install psycopg2 - pip install psycopg2
# - python3 db-creation.py - python3 db-creation.py
# environment: environment:
# POSTGRES_USER: MARIADB_USER:
# from_secret: db_user from_secret: db_user
# POSTGRES_PASSWORD: MARIADB_PASSWORD:
# from_secret: db_password from_secret: db_password
# depends_on: [ deploy-container-pgsql ] depends_on: [ deploy-container-db ]
#
# - name: build-image-server # - name: build-image-server
# image: plugins/docker # image: plugins/docker
# settings: # settings:

@ -1,8 +1,8 @@
import os import os
import psycopg2 import psycopg2
env_user = os.getenv('POSTGRES_USER') env_user = os.getenv('MARIADB_USER')
env_password = os.getenv('POSTGRES_PASSWORD') env_password = os.getenv('MARIADB_PASSWORD')
def executeDBQuery(query): def executeDBQuery(query):
conn = psycopg2.connect( conn = psycopg2.connect(
@ -16,34 +16,14 @@ def executeDBQuery(query):
cur.close() cur.close()
conn.close() conn.close()
create_db_query = '''
CREATE DATABASE bigbrother;
'''
create_schema_query = '''
CREATE SCHEMA IF NOT EXISTS public
AUTHORIZATION pg_database_owner;
COMMENT ON SCHEMA public
IS 'standard public schema';
GRANT USAGE ON SCHEMA public TO PUBLIC;
GRANT ALL ON SCHEMA public TO pg_database_owner;
'''
create_table_query = ''' create_table_query = '''
CREATE TABLE IF NOT EXISTS public.users CREATE TABLE IF NOT EXISTS users (
( spotifyid VARCHAR(255) NOT NULL,
spotifyid character varying COLLATE pg_catalog."default" NOT NULL, accesstoken VARCHAR(255),
accesstoken character varying COLLATE pg_catalog."default", refreshtoken VARCHAR(255),
refreshtoken character varying COLLATE pg_catalog."default", PRIMARY KEY (spotifyid)
CONSTRAINT users_pkey PRIMARY KEY (spotifyid) );
)
TABLESPACE pg_default;
''' '''
executeDBQuery(create_db_query)
executeDBQuery(create_schema_query)
executeDBQuery(create_table_query) executeDBQuery(create_table_query)
Loading…
Cancel
Save