Python - Phoenixdb is not returning column name with value instead it is returning list of values (row)











up vote
0
down vote

favorite












i am using phoenixdb library in python to fetch data from hbase, then after running sql queries, data is returning list of row values.



For example:
when i run the following query.



cursor.execute("Select * from user")
cursor.fetchall()


result is showing



[abc@any.com, 9876543120, 26, 12-12-1976]


instead of something like dictionary or associated array so that we can know key and value i.e., column name and its value



[email=>abc@any.com, phone=>9876543120, age=>26, dob=>12-12-1976]









share|improve this question


























    up vote
    0
    down vote

    favorite












    i am using phoenixdb library in python to fetch data from hbase, then after running sql queries, data is returning list of row values.



    For example:
    when i run the following query.



    cursor.execute("Select * from user")
    cursor.fetchall()


    result is showing



    [abc@any.com, 9876543120, 26, 12-12-1976]


    instead of something like dictionary or associated array so that we can know key and value i.e., column name and its value



    [email=>abc@any.com, phone=>9876543120, age=>26, dob=>12-12-1976]









    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      i am using phoenixdb library in python to fetch data from hbase, then after running sql queries, data is returning list of row values.



      For example:
      when i run the following query.



      cursor.execute("Select * from user")
      cursor.fetchall()


      result is showing



      [abc@any.com, 9876543120, 26, 12-12-1976]


      instead of something like dictionary or associated array so that we can know key and value i.e., column name and its value



      [email=>abc@any.com, phone=>9876543120, age=>26, dob=>12-12-1976]









      share|improve this question













      i am using phoenixdb library in python to fetch data from hbase, then after running sql queries, data is returning list of row values.



      For example:
      when i run the following query.



      cursor.execute("Select * from user")
      cursor.fetchall()


      result is showing



      [abc@any.com, 9876543120, 26, 12-12-1976]


      instead of something like dictionary or associated array so that we can know key and value i.e., column name and its value



      [email=>abc@any.com, phone=>9876543120, age=>26, dob=>12-12-1976]






      python-3.x hbase phoenix






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked yesterday









      vishal

      4721725




      4721725
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          If you want the results in the dictonary structure, set the cursorFactory while creating the cursor:



          cursor = conn.cursor(cursor_factory=phoenixdb.cursor.DictCursor)





          share|improve this answer





















          • it works! but when i try to access data["Email"]. It throws the error list indices must be integers or slices, not str
            – vishal
            23 hours ago










          • yeah, because fetchAll() will return a list. And columns are attribute of a list item. Hence you have to iterate the result list or use index.
            – Nishu Tayal
            23 hours ago










          • Yeah Got it. Thanks!
            – vishal
            23 hours ago












          • Cool, feel free to upvote or accept the answer if it helps :)
            – Nishu Tayal
            23 hours ago











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372221%2fpython-phoenixdb-is-not-returning-column-name-with-value-instead-it-is-returni%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote



          accepted










          If you want the results in the dictonary structure, set the cursorFactory while creating the cursor:



          cursor = conn.cursor(cursor_factory=phoenixdb.cursor.DictCursor)





          share|improve this answer





















          • it works! but when i try to access data["Email"]. It throws the error list indices must be integers or slices, not str
            – vishal
            23 hours ago










          • yeah, because fetchAll() will return a list. And columns are attribute of a list item. Hence you have to iterate the result list or use index.
            – Nishu Tayal
            23 hours ago










          • Yeah Got it. Thanks!
            – vishal
            23 hours ago












          • Cool, feel free to upvote or accept the answer if it helps :)
            – Nishu Tayal
            23 hours ago















          up vote
          0
          down vote



          accepted










          If you want the results in the dictonary structure, set the cursorFactory while creating the cursor:



          cursor = conn.cursor(cursor_factory=phoenixdb.cursor.DictCursor)





          share|improve this answer





















          • it works! but when i try to access data["Email"]. It throws the error list indices must be integers or slices, not str
            – vishal
            23 hours ago










          • yeah, because fetchAll() will return a list. And columns are attribute of a list item. Hence you have to iterate the result list or use index.
            – Nishu Tayal
            23 hours ago










          • Yeah Got it. Thanks!
            – vishal
            23 hours ago












          • Cool, feel free to upvote or accept the answer if it helps :)
            – Nishu Tayal
            23 hours ago













          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          If you want the results in the dictonary structure, set the cursorFactory while creating the cursor:



          cursor = conn.cursor(cursor_factory=phoenixdb.cursor.DictCursor)





          share|improve this answer












          If you want the results in the dictonary structure, set the cursorFactory while creating the cursor:



          cursor = conn.cursor(cursor_factory=phoenixdb.cursor.DictCursor)






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered yesterday









          Nishu Tayal

          10.9k73381




          10.9k73381












          • it works! but when i try to access data["Email"]. It throws the error list indices must be integers or slices, not str
            – vishal
            23 hours ago










          • yeah, because fetchAll() will return a list. And columns are attribute of a list item. Hence you have to iterate the result list or use index.
            – Nishu Tayal
            23 hours ago










          • Yeah Got it. Thanks!
            – vishal
            23 hours ago












          • Cool, feel free to upvote or accept the answer if it helps :)
            – Nishu Tayal
            23 hours ago


















          • it works! but when i try to access data["Email"]. It throws the error list indices must be integers or slices, not str
            – vishal
            23 hours ago










          • yeah, because fetchAll() will return a list. And columns are attribute of a list item. Hence you have to iterate the result list or use index.
            – Nishu Tayal
            23 hours ago










          • Yeah Got it. Thanks!
            – vishal
            23 hours ago












          • Cool, feel free to upvote or accept the answer if it helps :)
            – Nishu Tayal
            23 hours ago
















          it works! but when i try to access data["Email"]. It throws the error list indices must be integers or slices, not str
          – vishal
          23 hours ago




          it works! but when i try to access data["Email"]. It throws the error list indices must be integers or slices, not str
          – vishal
          23 hours ago












          yeah, because fetchAll() will return a list. And columns are attribute of a list item. Hence you have to iterate the result list or use index.
          – Nishu Tayal
          23 hours ago




          yeah, because fetchAll() will return a list. And columns are attribute of a list item. Hence you have to iterate the result list or use index.
          – Nishu Tayal
          23 hours ago












          Yeah Got it. Thanks!
          – vishal
          23 hours ago






          Yeah Got it. Thanks!
          – vishal
          23 hours ago














          Cool, feel free to upvote or accept the answer if it helps :)
          – Nishu Tayal
          23 hours ago




          Cool, feel free to upvote or accept the answer if it helps :)
          – Nishu Tayal
          23 hours ago


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372221%2fpython-phoenixdb-is-not-returning-column-name-with-value-instead-it-is-returni%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

          SQL update select statement

          'app-layout' is not a known element: how to share Component with different Modules