helper.py
def check_language(content_type, lang):
    '''
    Function to check language and choose correct table in database
    Args: content_type = str; the content that should be queried from the databases
          lang = str; language
    Returns: df_row = contains results from sql query
    '''

    # connect to database
    DATABASE_URL = os.environ['DATABASE_URL']
    conn = psycopg2.connect(DATABASE_URL, sslmode='require')
    cur = conn.cursor()

    # select everything from the titles database
    if lang == 'de':
        if content_type == 'title':
            cur.execute("SELECT content FROM titles")
            db_row = cur.fetchall()
            # close database connection
            conn.close()
        elif content_type == 'portfolio':
            cur.execute("SELECT * FROM portfolio")
            db_row = cur.fetchall()
            # close database connection
            conn.close()
        elif content_type == 'skills':
            cur.execute("SELECT * FROM skills")
            db_row = cur.fetchall()
            # close database connection
            conn.close()

    elif lang == 'en':
        if content_type == 'title':
            cur.execute("SELECT content FROM titles_en")
            db_row = cur.fetchall()
            # close database connection
            conn.close()
        elif content_type == 'portfolio':
            cur.execute("SELECT * FROM portfolio_en")
            db_row = cur.fetchall()
            # close database connection
            conn.close()
        elif content_type == 'skills':
            cur.execute("SELECT * FROM skills_en")
            db_row = cur.fetchall()
            # close database connection
            conn.close()

    return db_row

    Function to check language and choose correct table in database
    Args: content_type = str; the content that should be queried from the databases
          lang = str; language
    Returns: df_row = contains results from sql query
    
Function to check language and choose correct table in database
Args: content_type = str; the content that should be queried from the databases
lang = str; language
Returns: df_row = contains results from sql query
Function to check language and choose correct table in database Args : content_type = str ; the content that should be queried from the databases lang = str ; language Returns : df_row = contains results from sql query
def check_language(content_type, lang):
    DATABASE_URL = os.environ['DATABASE_URL']
    conn = psycopg2.connect(DATABASE_URL, sslmode='require')
    cur = conn.cursor()
    if lang == 'de':
        if content_type == 'title':
            cur.execute("SELECT content FROM titles")
            db_row = cur.fetchall()
            conn.close()
        elif content_type == 'portfolio':
            cur.execute("SELECT * FROM portfolio")
            db_row = cur.fetchall()
            conn.close()
        elif content_type == 'skills':
            cur.execute("SELECT * FROM skills")
            db_row = cur.fetchall()
            conn.close()
    elif lang == 'en':
        if content_type == 'title':
            cur.execute("SELECT content FROM titles_en")
            db_row = cur.fetchall()
            conn.close()
        elif content_type == 'portfolio':
            cur.execute("SELECT * FROM portfolio_en")
            db_row = cur.fetchall()
            conn.close()
        elif content_type == 'skills':
            cur.execute("SELECT * FROM skills_en")
            db_row = cur.fetchall()
            conn.close()
    return db_row
def check_language ( content_type , lang ) : DATABASE_URL = os . environ [ 'DATABASE_URL' ] conn = psycopg2 . connect ( DATABASE_URL , sslmode = 'require' ) cur = conn . cursor ( ) if lang == 'de' : if content_type == 'title' : cur . execute ( "SELECT content FROM titles" ) db_row = cur . fetchall ( ) conn . close ( ) elif content_type == 'portfolio' : cur . execute ( "SELECT * FROM portfolio" ) db_row = cur . fetchall ( ) conn . close ( ) elif content_type == 'skills' : cur . execute ( "SELECT * FROM skills" ) db_row = cur . fetchall ( ) conn . close ( ) elif lang == 'en' : if content_type == 'title' : cur . execute ( "SELECT content FROM titles_en" ) db_row = cur . fetchall ( ) conn . close ( ) elif content_type == 'portfolio' : cur . execute ( "SELECT * FROM portfolio_en" ) db_row = cur . fetchall ( ) conn . close ( ) elif content_type == 'skills' : cur . execute ( "SELECT * FROM skills_en" ) db_row = cur . fetchall ( ) conn . close ( ) return db_row
Function to check language and choose correct table in database
Args: content_type = str; the content that should be queried from the databases
lang = str; language
Returns: df_row = contains results from sql query
Function to check language and choose correct table in database Args : content_type = str ; the content that should be queried from the databases lang = str ; language Returns : df_row = contains results from sql query
'''
    Function to check language and choose correct table in database
    Args: content_type = str; the content that should be queried from the databases
          lang = str; language
    Returns: df_row = contains results from sql query
    ''' # connect to database # select everything from the titles database # close database connection # close database connection # close database connection # close database connection # close database connection # close database connection
content_type
lang