annotate doc/FAQ.txt @ 66:5a7c30cd9de2 MySQLdb

By exposing connection on result, decoders can be simplified: Only the field object is needed. Turned on leak testing and found a leak writing BLOBs. removed one of the old stubs in Cursor.
author adustman
date Sun, 29 Mar 2009 16:26:30 +0000
parents e48810735f11
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
1 ====================================
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
2 MySQLdb Frequently Asked Questions
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
3 ====================================
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
4
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
5 .. contents::
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
6 ..
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
7
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
8
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
9 Build Errors
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
10 ------------
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
11
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
12 ld: fatal: library -lmysqlclient_r: not found
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
13
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
14 mysqlclient_r is the thread-safe library. It's not available on
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
15 all platforms, or all installations, apparently. You'll need to
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
16 reconfigure site.cfg (in MySQLdb-1.2.1 and newer) to have
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
17 threadsafe = False.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
18
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
19 mysql.h: No such file or directory
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
20
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
21 This almost always mean you don't have development packages
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
22 installed. On some systems, C headers for various things (like MySQL)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
23 are distributed as a seperate package. You'll need to figure out
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
24 what that is and install it, but often the name ends with -devel.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
25
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
26 Another possibility: Some older versions of mysql_config behave oddly
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
27 and may throw quotes around some of the path names, which confused
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
28 MySQLdb-1.2.0. 1.2.1 works around these problems. If you see things
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
29 like -I'/usr/local/include/mysql' in your compile command, that's
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
30 probably the issue, but it shouldn't happen any more.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
31
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
32
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
33 ImportError
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
34 -----------
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
35
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
36 ImportError: No module named _mysql
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
37
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
38 If you see this, it's likely you did some wrong when installing
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
39 MySQLdb; re-read (or read) README. _mysql is the low-level C module
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
40 that interfaces with the MySQL client library.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
41
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
42 Various versions of MySQLdb in the past have had build issues on
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
43 "weird" platforms; "weird" in this case means "not Linux", though
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
44 generally there aren't problems on Unix/POSIX platforms, including
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
45 BSDs and Mac OS X. Windows has been more problematic, in part because
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
46 there is no `mysql_config` available in the Windows installation of
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
47 MySQL. 1.2.1 solves most, if not all, of these problems, but you will
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
48 still have to edit a configuration file so that the setup knows where
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
49 to find MySQL and what libraries to include.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
50
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
51
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
52 ImportError: libmysqlclient_r.so.14: cannot open shared object file: No such file or directory
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
53
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
54 The number after .so may vary, but this means you have a version of
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
55 MySQLdb compiled against one version of MySQL, and are now trying to
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
56 run it against a different version. The shared library version tends
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
57 to change between major releases.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
58
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
59 Solution: Rebuilt MySQLdb, or get the matching version of MySQL.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
60
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
61 Another thing that can cause this: The MySQL libraries may not be on
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
62 your system path.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
63
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
64 Solutions:
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
65
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
66 * set the LD_LIBRARY_PATH environment variable so that it includes
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
67 the path to the MySQL libraries.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
68
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
69 * set static=True in site.cfg for static linking
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
70
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
71 * reconfigure your system so that the MySQL libraries are on the
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
72 default loader path. In Linux, you edit /etc/ld.so.conf and run
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
73 ldconfig. For Solaris, see `Linker and Libraries Guide
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
74 <http://docs.sun.com/app/docs/doc/817-3677/6mj8mbtbe?a=view>`_.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
75
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
76
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
77 ImportError: ld.so.1: python: fatal: libmtmalloc.so.1: DF_1_NOOPEN tagged object may not be dlopen()'ed
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
78
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
79 This is a weird one from Solaris. What does it mean? I have no idea.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
80 However, things like this can happen if there is some sort of a compiler
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
81 or environment mismatch between Python and MySQL. For example, on some
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
82 commercial systems, you might have some code compiled with their own
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
83 compiler, and other things compiled with GCC. They don't always mesh
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
84 together. One way to encounter this is by getting binary packages from
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
85 different vendors.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
86
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
87 Solution: Rebuild Python or MySQL (or maybe both) from source.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
88
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
89 ImportError: dlopen(./_mysql.so, 2): Symbol not found: _sprintf$LDBLStub
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
90 Referenced from: ./_mysql.so
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
91 Expected in: dynamic lookup
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
92
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
93 This is one from Mac OS X. It seems to have been a compiler mismatch,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
94 but this time between two different versions of GCC. It seems nearly
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
95 every major release of GCC changes the ABI in some why, so linking
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
96 code compiled with GCC-3.3 and GCC-4.0, for example, can be
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
97 problematic.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
98
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
99
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
100 My data disappeared! (or won't go away!)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
101 ----------------------------------------
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
102
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
103 Starting with 1.2.0, MySQLdb disables autocommit by default, as
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
104 required by the DB-API standard (`PEP-249`_). If you are using InnoDB
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
105 tables or some other type of transactional table type, you'll need
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
106 to do connection.commit() before closing the connection, or else
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
107 none of your changes will be written to the database.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
108
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
109 Conversely, you can also use connection.rollback() to throw away
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
110 any changes you've made since the last commit.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
111
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
112 Important note: Some SQL statements -- specifically DDL statements
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
113 like CREATE TABLE -- are non-transactional, so they can't be
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
114 rolled back, and they cause pending transactions to commit.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
115
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
116
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
117 Other Errors
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
118 ------------
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
119
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
120 OperationalError: (1251, 'Client does not support authentication protocol requested by server; consider upgrading MySQL client')
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
121
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
122 This means your server and client libraries are not the same version.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
123 More specifically, it probably means you have a 4.1 or newer server
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
124 and 4.0 or older client. You can either upgrade the client side, or
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
125 try some of the workarounds in `Password Hashing as of MySQL 4.1
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
126 <http://dev.mysql.com/doc/refman/5.0/en/password-hashing.html>`_.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
127
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
128
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
129 Other Resources
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
130 ---------------
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
131
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
132 * Help forum. Please search before posting.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
133
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
134 * `Google <http://www.google.com/>`_
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
135
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
136 * READ README!
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
137
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
138 * Read the User's Guide
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
139
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
140 * Read `PEP-249`_
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
141
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
142 .. _`PEP-249`: http://www.python.org/peps/pep-0249.html
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
143