python mysqldb DictCursor 이용하기
아무래도 제일많이 사용하는게 mysql 이고 python 으로 연동하기 위해서 MySQLdb 를 사용하는데 맨날 기존 cursor를 이용해서 데이터를 가져오곤 했다.
- BaseCursor
- The base class for Cursor objects. This does not raise Warnings.
- CursorStoreResultMixIn
- Causes the Cursor to use the mysqlstoreresult() function to get the query result. The entire result set is stored on the client side.
- CursorUseResultMixIn
- Causes the cursor to use the mysqluseresult() function to get the query result. The result set is stored on the server side and is transferred row by row using fetch operations.
- CursorTupleRowsMixIn
- Causes the cursor to return rows as a tuple of the column values.
Causes the cursor to return rows as a dictionary, where the keys are column names and the values are column values. Note that if the column names are not unique, i.e., you are selecting from two tables that share column names, some of them will be rewritten as table.column. This can be avoided by using the SQL AS keyword. (This is yet-another reason not to use * in SQL queries, particularly where JOIN is involved.)
- Cursor
- The default cursor class. This class is composed of CursorWarningMixIn, CursorStoreResultMixIn, CursorTupleRowsMixIn, and BaseCursor, i.e. it raises Warning, usesmysqlstoreresult(), and returns rows as tuples.
- DictCursor
- Like Cursor except it returns rows as dictionaries.
- SSCursor
- A “server-side” cursor. Like Cursor but uses CursorUseResultMixIn. Use only if you are dealing with potentially large result sets.
- SSDictCursor
- Like SSCursor except it returns rows as dictionaries.
2013/07/09 – [Programming/DB] – (stackoverflow) how to improve select performance in mysql?
2013/07/04 – [Programming/DB] – (mysql) mysqldump 을 이용한 백업 스크립트
2013/06/28 – [Programming/DB] – (mysql) insert 시간 자동 추가하기
2013/06/26 – [Programming/DB] – (mysql) Data truncation: Data too long for column ‘xxx’ at row 1
2012/11/07 – [Programming/iOS] – (iOS) iOS앱 – mysql 연동, 이렇게 하면 쉽다.
2012/10/31 – [Technique] – mac에 mysql 설치 관련 링크 정리, 이것만 알면돼!!