Initialize PostgreSQL Database
    
    .. note:: psycopg2 or similar driver required
    
    Args:
        username(str): Database username.
        host(str): Database host URL.
        database(str): Database name.
        port(Optional[int,str]): Database port.
        password(Optional[str]): Database password.
        initTime(Optional[bool]): If True, it will print the amount of time to generate database.

    Example::
    
        from gsshapy.lib.db_tools import init_postgresql_db, create_session
        
        sqlalchemy_url = init_postgresql_db(username='gsshapy', 
                                            host='localhost', 
                                            database='gsshapy_mysql_tutorial', 
                                            port='5432', 
                                            password='pass')

        db_work_sessionmaker = get_sessionmaker(sqlalchemy_url)

        db_work_session = db_work_sessionmaker()
        
        ##DO WORK
        
        db_work_session.close()

def init_postgresql_db(username, host, database, port='', password='', initTime=False):
    """
    Initialize PostgreSQL Database
    
    .. note:: psycopg2 or similar driver required
    
    Args:
        username(str): Database username.
        host(str): Database host URL.
        database(str): Database name.
        port(Optional[int,str]): Database port.
        password(Optional[str]): Database password.
        initTime(Optional[bool]): If True, it will print the amount of time to generate database.

    Example::
    
        from gsshapy.lib.db_tools import init_postgresql_db, create_session
        
        sqlalchemy_url = init_postgresql_db(username='gsshapy', 
                                            host='localhost', 
                                            database='gsshapy_mysql_tutorial', 
                                            port='5432', 
                                            password='pass')

        db_work_sessionmaker = get_sessionmaker(sqlalchemy_url)

        db_work_session = db_work_sessionmaker()
        
        ##DO WORK
        
        db_work_session.close()
    """
    postgresql_base_url = 'postgresql://'
    
    if password != '':
        password = ':%s' % password
        
    if port != '':
        port = ':%s' % port
        
    sqlalchemy_url = '%s%s%s@%s%s/%s' % (
                      postgresql_base_url,
                      username,
                      password,
                      host,
                      port,
                      database
                      )
    
    init_time = init_db(sqlalchemy_url)
    
    if initTime:
        print('TIME: {0} seconds'.format(init_time))
    
    return sqlalchemy_url