And what about list comprehensions? If result is ((123,), (234,), (345,))
:
>>> row = [item[0] for item in cursor.fetchall()]
>>> row
[123, 234, 345]
If result is ({'id': 123}, {'id': 234}, {'id': 345})
:
>>> row = [item['id'] for item in cursor.fetchall()]
>>> row
[123, 234, 345]
More Related Contents:
- Install mysql-python (Windows)
- What is PyMySQL and how does it differ from MySQLdb? Can it affect Django deployment?
- ‘pip’ is not recognized as an internal or external command
- What is the difference between null=True and blank=True in Django?
- Using Django time/date widgets in custom form
- Difference between static STATIC_URL and STATIC_ROOT on Django
- Django Query That Get Most Recent Objects From Different Categories
- Django rest framework serializing many to many field
- How to compare two JSON objects with the same elements in a different order equal?
- Installing mysqlclient in Python 3.6 in windows
- Best practices for adding .gitignore file for Python projects? [closed]
- How do I get the object if it exists, or None if it does not exist in Django?
- Find object in list that has attribute equal to some value (that meets any condition)
- Django Model MultipleChoice
- No web processes running Django in heroku
- Django – what is the difference between render(), render_to_response() and direct_to_template()?
- Django: CSRF token missing or incorrect
- Unresolved attribute reference ‘objects’ for class ” in PyCharm
- Can’t install mysql-python (newer versions) in Windows
- gunicorn command not found, but it’s in my requirements.txt
- How to move a model between two Django apps (Django 1.7)
- How to change ForeignKey display text in the Django Admin?
- How can I register a single view (not a viewset) on my router?
- auth.User.groups: (fields.E304) Reverse accessor for ‘User.groups’ clashes with reverse accessor for ‘UserManage.groups’
- Django Admin Page missing CSS
- Good ways to sort a queryset? – Django
- Django — Conditional Login Redirect
- How do I access dictionary keys that contain hyphens from within a Django template?
- How to properly use the “choices” field option in Django
- How to use custom AdminSite class?