The python standard mysql library returns tuples from cursor.execute. To get at the question_id field you’d use row[0]
, not row['question_id']
. The fields come out in the same order that they appear in the select statement.
A decent way to extract multiple fields is something like
for row in cursor.execute("select question_id, foo, bar from questions"): question_id, foo, bar = row
Related Posts:
- What are “named tuples” in Python?
- django: TypeError: ‘tuple’ object is not callable
- Python convert tuple to string
- Convert list to tuple in Python
- Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock
- Python add item to the tuple
- Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock
- Setting Django up to use MySQL
- ImportError: No module named MySQLdb
- How to sort a list/tuple of lists/tuples by the element at a given index?
- Append a tuple to a list – what’s the difference between two ways?
- Add Variables to Tuple
- What’s the difference between lists enclosed by square brackets and parentheses in Python?
- Why is there no tuple comprehension in Python?
- Why is there no tuple comprehension in Python?
- ImportError: No module named mysql.connector using Python2
- ImportError: No module named ‘MySQL’
- How does tuple comparison work in Python?
- What is the easiest way to clear a database from the CLI with manage.py in Django?
- TypeError: can only concatenate tuple (not “str”) to tuple Error
- creating sets of tuples in python
- TypeError: can only concatenate tuple (not “int”) in Python
- Error loading MySQLdb module: No module named ‘MySQLdb’
- Can I put a tuple into an array in python?
- Python convert tuple to string
- Does Python have an immutable list?
- How can I reverse a list in Python?
- How to use filter, map, and reduce in Python 3
- What does enumerate() mean?
- Does Python have a ternary conditional operator?
- What is the difference between Python’s list methods append and extend?
- Iterating over dictionaries using ‘for’ loops
- how to sort pandas dataframe from one column
- How can I split and parse a string in Python?
- numpy matrix vector multiplication
- whitespace in regular expression
- How do I read CSV data into a record array in NumPy?
- Basic explanation of python functions
- TypeError: ‘Series’ objects are mutable, thus they cannot be hashed problemwith column
- How to rename a file using Python
- Cosine Similarity between 2 Number Lists
- How to install python3 version of package via pip on Ubuntu?
- ValueError: Length of values does not match length of index | Pandas DataFrame.unique()
- unhashable type: ‘dict’ Type Error [duplicate]
- How to check whether a str(variable) is empty or not?
- Clear variable in python
- Python 3.6.0 syntax error “Missing parentheses in call to ‘print’ [duplicate]
- How to get coverage reporting when testing a pytest plugin?
- TypeError: method() takes 1 positional argument but 2 were given
- is not JSON serializable
- Tkinter understanding mainloop
- How can I rename a conda environment?
- django import error – No module named core.management
- How to change a ‘LinearSegmentedColormap’ to a different distribution of color?
- Using python’s eval() vs. ast.literal_eval()
- How can I stop a While loop?
- Create own colormap using matplotlib and plot color scale
- The difference between ‘+=’ and ‘=+’?
- How to fix “Attempted relative import in non-package” even with __init__.py
- Sorting a set of values
- Git Bash won’t run my python files?
- Python: Declare as integer and character
- How to install pytorch in windows?
- Python TypeError must be str not int
- “Unicode Error “unicodeescape” codec can’t decode bytes… Cannot open text files in Python 3
- Pandas join issue: columns overlap but no suffix specified
- How to downgrade python from 3.7 to 3.6
- How to turn on line numbers in IDLE?
- OpenCV NoneType object has no attribute shape
- How to use an image for the background in tkinter?
- Python locale error: unsupported locale setting
- Using Look Up Tables in Python
- Parallel Python: What is a callback?
- ImportError: libGL.so.1: cannot open shared object file: No such file or directory
- ImportError: No module named Crypto.Cipher
- Not able to pip install pickle in python 3.6
- How to print Unicode character in Python?
- Coalesce values from 2 columns into a single column in a pandas dataframe
- Unknown format code ‘f’ for object of type ‘str’- Folium
- Pyinstaller setting icons don’t change
- No module named ‘tqdm’
- Compute a confidence interval from sample data
- Can not click on a Element: ElementClickInterceptedException in Splinter / Selenium
- How to split elements of a list?
- How can I find script’s directory?
- Porting Perl to Python
- Find object in list that has attribute equal to some value (that meets any condition)
- What is the purpose of the single underscore “_” variable in Python?
- Must have equal len keys and value when setting with an iterable
- print(__doc__) in Python 3 script
- Convert a 1D array to a 2D array in numpy
- How to print a linebreak in a python function?
- ‘module’ has no attribute ‘urlencode’
- Cannot concatenate ‘str’ and ‘float’ objects?
- Python Text Menu Infinite Loop
- Install pip for python 3.5
- How do I represent and work with n-bit vectors in Python?
- How to repeat individual characters in strings in Python
- ValueError: Cannot set a frame with no defined index and a value that cannot be converted to a Series
- SMTP AUTH extension not supported by server