Wednesday, January 29, 2014

Clone/Copy Table Schema From One Database To Another - SQLalchemy

I got the following code from slide 36 of this slideshow:


  1. thank you!! definitely a lifesaver.

  2. Good morning! I would like to use Bonobo: gragh to copy and paste the values ​​of one initial table into another.
    return bonobo.Graph (
            bonobo.PrettyPrinter ()
    I can't figure out if it is necessary to pass the final formatted data like a shareholder
        # tgt_row = [
        # {'batch_id': 1, 'name_of_batch': 'aaaaaaa'},
        # {'batch_id': 2, 'name_of_batch': 'bbbbbbb'},
        # {'batch_id': 3, 'name_of_batch': 'ccccc'},
        # {'batch_id': 4, 'name_of_batch': 'dddd'}

    When I try to build the dict I can't format it in the right way and only the last cycle is stored, even if I use a list and add the dict

    def transform (arr_values, arr_key):
        # {'batch_id': 1, 'name_of_batch': 'aaaaaaa'},
        support = []
        finalDict = {}
        params = []
         for v in arr_values:
            print ('=====> START support, support)
         for val, k in zip (v, arr_key): # 1 aaaaa
                 print ('val', val)
                 print ('k', k)
              for val, k in zip (v, arr_key):
                     finalDict [k] = val
                     appoggio.append (finalDict)
                  print ('=====> finalDict', finalDict)
                 print ('I go out')
        print ('END =====> support', params)
        return support

    Is this the right approach?