Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103167
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: pymysql question |
| Date | Thu, 18 Feb 2016 22:06:05 -0500 |
| Organization | IISS Elusive Unicorn |
| Lines | 34 |
| Message-ID | <mailman.33.1455851173.2289.python-list@python.org> (permalink) |
| References | <0b27ecb5-4a3e-46dc-a83c-5ce806f46051@googlegroups.com> <56C5BE90.4050500@mrabarnett.plus.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de lPXOGxtBjQYYb4Q/i2qQjQ+lxM3yFBSWoXsXeTDcSZAQ== |
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'mrab': 0.05; 'column': 0.07; 'subject:question': 0.08; 'attribute.': 0.09; 'cursor': 0.09; 'dict': 0.09; 'message-id:@4ax.com': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rows': 0.09; 'python': 0.10; 'thu,': 0.15; '2016': 0.16; '>on': 0.16; 'compliant,': 0.16; 'lowercase': 0.16; 'mixture': 0.16; 'names?': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'row': 0.16; 'wrote:': 0.16; "shouldn't": 0.18; 'url:home': 0.18; 'names.': 0.22; 'feb': 0.23; 'tables': 0.23; 'this:': 0.23; 'header:X-Complaints-To:1': 0.26; 'actual': 0.28; 'url:peps': 0.29; 'query': 0.30; 'table': 0.32; 'url:python': 0.33; 'could': 0.35; 'mapping': 0.35; 'url:dev': 0.35; 'url:org': 0.36; 'possible': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'charset:us- ascii': 0.37; 'doing': 0.38; 'names': 0.38; 'skip:p 20': 0.38; 'build': 0.40; 'to:addr:python.org': 0.40; 'field': 0.60; 'email addr:gmail.com': 0.62; 'results': 0.66; 'upper': 0.76; '>you': 0.84; 'dennis': 0.91; 'received:108': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | adsl-108-68-179-144.dsl.klmzmi.sbcglobal.net |
| X-Newsreader | Forte Agent 6.00/32.1186 |
| X-No-Archive | YES |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21rc2 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:103167 |
Show key headers only | View raw
On Thu, 18 Feb 2016 12:52:32 +0000, MRAB <python@mrabarnett.plus.com>
declaimed the following:
>On 2016-02-18 12:08, tdsperth@gmail.com wrote:
>> Hi All
>>
>> I have many mysql tables in a conversion I am doing - the table field names are a mixture of lower case and upper case - do I have to covert all to one case to over come Python not finding the field.
>>
>> rows ocur.fetchall()
>> for row in rows:
>> print(row['newname'])
>> #which fails because it is upper case in the table
>>
>According to this:
>
>MySQL query to get column names?
>http://stackoverflow.com/questions/4165195/mysql-query-to-get-column-names
>
>it's possible to get the column names.
>
>You could then build a dict to map a lowercase column name to an actual
>column name.
Uhm... If pymysql is db-api compliant, you shouldn't need a query just
for the names... Any cursor that returns results has a description of the
fields in that result...
https://www.python.org/dev/peps/pep-0249/#cursor-attributes
One could build the mapping from the cursor.description attribute.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
pymysql question tdsperth@gmail.com - 2016-02-18 04:08 -0800 Re: pymysql question MRAB <python@mrabarnett.plus.com> - 2016-02-18 12:52 +0000 Re: pymysql question Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-02-18 22:06 -0500
csiph-web