vendredi 10 juillet 2015

Get database fields from sqlite db from function use_specific_path()

I have a function use_specific_path() which gathers three fields: id, source, destination based on an id passed to use_specific_id() function.

def use_specific_path(id):
    dbconn = sqlite3.connect('./syncdb.db')
    cursor = dbconn.cursor()
    specific_path = cursor.execute(''' SELECT * FROM paths WHERE id = ? ''', (id,) )
    specific_row = cursor.fetchall()
    #return specific_row

def clone_saved_path():
    show_your_paths = input('Do you want to view your current paths? [1] Yes [2] No ')
    show_your_paths = int(show_your_paths)
    if show_your_paths == 1:
        show_paths()
        path_chosen_to_clone = input('Which path would you like to clone? Enter a number ')
        path_chosen_to_clone = int(path_chosen_to_clone)
        #print( type(path_chosen_to_clone) ) 

        # for path_chosen_to_clone ... gather source and destination fields from use_specific_path(),
        # then run path_clone(source, destination)
        for chosen_path in path_chosen_to_clone:


            source_dir_prompt = <<value from source in db>>
            destination_dir_prompt = <<value from destination in db>>

            path_clone(source_dir_prompt, destination_dir_prompt)

I'm trying to capture the values of source, and destination and use them in another function called path_clone() . I need to basically write the values to variables I've already created in clone_saved_path() called source_dir_prompt and source_dir_prompt - can someone help me out here? Thanks.

Aucun commentaire:

Enregistrer un commentaire