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]
python-3.x hbase phoenix
add a comment |
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]
python-3.x hbase phoenix
add a comment |
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]
python-3.x hbase phoenix
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
python-3.x hbase phoenix
asked yesterday
vishal
4721725
4721725
add a comment |
add a comment |
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)
it works! but when i try to accessdata["Email"]
. It throws the errorlist 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
add a comment |
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)
it works! but when i try to accessdata["Email"]
. It throws the errorlist 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
add a comment |
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)
it works! but when i try to accessdata["Email"]
. It throws the errorlist 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
add a comment |
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)
If you want the results in the dictonary structure, set the cursorFactory while creating the cursor:
cursor = conn.cursor(cursor_factory=phoenixdb.cursor.DictCursor)
answered yesterday
Nishu Tayal
10.9k73381
10.9k73381
it works! but when i try to accessdata["Email"]
. It throws the errorlist 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
add a comment |
it works! but when i try to accessdata["Email"]
. It throws the errorlist 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
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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