Commit Graph

42 Commits

Author SHA1 Message Date
adustman
d72f605a67 Calls to _mysql__fetch_row() might move the row tuple, so use a PyObject **.
Thanks to Andy Martin for finding this.
2001-04-28 00:39:06 +00:00
adustman
a537e7a578 Update exception generation. 2001-04-22 00:13:33 +00:00
adustman
40c7a6383e Mark connection open, even if open failed, for proper error reporting.
Then mark it closed so we don't try to close it.
2001-04-19 17:41:22 +00:00
adustman
233217ce24 Be more paranoid about operating on closed connections. 2001-04-19 17:32:53 +00:00
adustman
31fb50202d Lots of new __doc__ strings and other odds and ends
for new pydoc module in Python 2.1.

Exceptions have been moved into _mysql_const/exc.py.
Mostly this is for documentation purposes. Mostly.
2001-04-18 04:06:04 +00:00
adustman
bfbc41aaa8 Missed a Py_INCREF()! Does not seem to affect Python 1.5.2.
Does affect Python 2.1b1.
2001-03-17 01:52:05 +00:00
adustman
e17cb128f7 Clean up insignificant compiler warnings. 2001-03-17 00:39:25 +00:00
adustman
e00de5823c Finally, a definitive way to determine if transactions are available. 2001-03-12 18:08:02 +00:00
adustman
84bedad4a4 Find and plug memory leak. 2001-03-12 02:58:03 +00:00
adustman
05bbca4215 Move constants to external package. 2001-03-12 01:27:45 +00:00
adustman
d480ad766a Update docs.
result.fetch_row(0,how) returns all rows of the rsult set as a tuple.
2001-01-27 02:32:00 +00:00
adustman
57319a3928 Finishing touches. 2000-12-01 02:25:12 +00:00
adustman
5ea99b0b76 Minor updates. 2000-12-01 01:46:43 +00:00
adustman
7100769c8c New quoting mechanism. 2000-10-31 19:53:43 +00:00
adustman
21846c7d2a Move escape_dict functionality into _mysql.
str(long) in Python 2.0 doesn't add a trailing L.
2000-10-23 22:52:01 +00:00
adustman
1d7e1a35d0 Add function prototypes to appease compiler. 2000-10-17 17:41:02 +00:00
adustman
9eaee1765b Modify quoting for MySQL-3.23.
Implement mysql_options() as keyword options to the connect method.
2000-08-09 20:21:08 +00:00
adustman
47edf13df1 Fix memory leak (maybe). 2000-07-11 20:56:29 +00:00
adustman
8e3ad9b07c Add missing casts. 2000-05-03 02:07:25 +00:00
adustman
ad5a4e3056 Optimization (I hope). 2000-05-02 04:39:51 +00:00
adustman
3bc2e7a9d3 A big (I hope) optimization and hooks for transaction support. 2000-03-28 17:09:29 +00:00
adustman
a57d4c439c Make keys for rows returned as dictionary unique by using
"table.column" instead of "column" when there are two columns
in the result set with the same name.
2000-03-24 05:47:17 +00:00
adustman
abfd616405 Add some support for MySQL-3.23 features.
Fixed a few miscellaneous things.
2000-03-14 04:47:52 +00:00
adustman
ad6b9b7b39 Add support for returning values as dictionaries a la MySQLmodule. 2000-03-08 22:29:35 +00:00
adustman
83643b4935 Bug fixes. 2000-03-08 21:53:06 +00:00
adustman
42bd06e986 Add a dictionary that controls conversion of Python types into
MySQL literals.
2000-01-07 00:30:44 +00:00
adustman
e557a5e93f User-contributed bugfixes. 1999-10-12 01:55:45 +00:00
adustman
fd4d0d2a2e Fix a memory leak. Add some user-contributed patches so that it works
in the Evil OS.
1999-09-14 21:20:17 +00:00
adustman
5d45e44593 Avoid core dump if exception occurs during connect. 1999-08-02 04:24:36 +00:00
adustman
f88e77d033 Minor tweaks.
ZMySQLDA.patch makes Zope's ZMySQLDA compatible with MySQLdb (maybe).
1999-07-20 04:04:20 +00:00
adustman
c3d23b6858 _mysql: Move type converter initialization outside of module. When opening
the connection, a mapping of MySQL types to Python functions may be passed
as the keyword argument conv. This is stored as the converter attribute
on the connection object, and may be modified, assigned, etc.

MySQLdb: Build full converter dictionary, pass along to _mysql when
creating a connection.

MySQL_doc: Fixed a minor documentation bug.
1999-07-15 22:14:42 +00:00
adustman
2353d9ff30 Minor user-contributed stuff. 1999-07-08 03:05:10 +00:00
adustman
b5386a028a Adds doc generator, license agreement.
Minor bugfix on _mysqlmodule.c.
1999-04-06 20:03:17 +00:00
adustman
7be272c332 __doc__ strings. 1999-04-01 06:45:02 +00:00
adustman
675b285a7b Minor bugfix on _mysql: Set exception if non-sequence is passed to
escape_row().

Updating for version 2.0 of the API.
1999-03-30 07:59:51 +00:00
adustman
8ac921c304 Added some new result object methods for fetching many or all rows,
which should speed things up a bit. Not that it's slow...

Records whether the result was obtained by mysql_store_result or
mysql_use_result so it can avoid giving up the global interpreter
lock when store was used. I'm assuming the other functions which
return a result set (i.e. mysql_list_dbs, mysql_list_tables, etc.)
effectively use mysql_store_result.
1999-03-25 07:11:24 +00:00
adustman
31a706efde Finally chased down an ugly memory leak in _mysql. Tested with a script
I got from mxODBC author Marc-Andre Lemburg, which revealed the leak in
the first place.

Added a connection.rollback() method that always raises an
OperationalError, since MySQL doesn't have transactions.
connection.commit() still succeeds without doing anything.
1999-03-18 06:20:14 +00:00
adustman
e1970cf20b Updated _mysql to do some type conversion. Adds a dictionary type_conv
which makes MySQL field types to Python functions which perform the
conversion. All numeric types except DECIMAL are mapped into either
PyInt or PyLong, and the floating point types are mapped into PyFloat by
default. Types which are not represented in the dictionary are returned
as strings.

Modified MySQLdb to adjust type_conv so that the various date/time types
are returned as DateTime objects.

Bug: If you were to delete or assign type_conv, bad things would happen.
I haven't actually tried this, but it wouldn't be good. May add an extra
reference count to prevent this, haven't really decided.
1999-03-17 02:20:42 +00:00
adustman
161f66f556 Added a _mysql.quote_row() function which takes a row of data as a tuple
and quotes it, converting None into NULL.

MySQLdb.py is the DBI-1.1 compatible wrapper.

To do: Type conversions for fetch_row().
1999-03-16 05:22:46 +00:00
adustman
563ab10307 Added access to various MySQL constants, plus field flags. More specific
exception handling. And a light sprinkling of bug fixes throughout.

I'm thinking this part is done, unless I find the need to add another
feature or two for the Python DBI. All the mysql_* calls are duplicated
either as functions, connection objects, or result objects, with the
exception of deprecated functions and a lot of field_* functions.
Access to the MYSQL_FIELD members is done mostly through
ResultObject.describe(), which returns almost all information for all
the fields. ResultObject.field_flags() returns the flag values.
1999-03-13 09:32:38 +00:00
adustman
c02de220c3 Nearly everything that should work now works. Need to add a few more
methods to the Result object. Also need to rip out the Field object;
ended up not needing it. It's just cruft now.

Python 1.5.2b2 (#1, Feb 18 1999, 18:20:08)  [GCC egcs-2.90.29 980515 (egcs-1.0.3 re on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import _mysql
>>> c=_mysql.connect(passwd='foobar',db='vmail')
>>> c.query("insert into Users (Name, Mailbox, Forward) values ('Ed Landa', 'elanda', 'elanda@beavis.comstar.net')")
>>> c.affected_rows()
1L
>>> c.query("select * from Users")
>>> r=c.store_result()
>>> r.describe()
(('Handle', 253, 0, 16, 16, 0, 1), ('UNIXpasswd', 253, 0, 16, 16, 0, 1), ('Name', 253, 8, 64, 64, 0, 1), ('Mailbox', 253, 8, 64, 64, 0, 0), ('DomainName', 253, 0, 64, 64, 0, 0), ('Forward', 252, 25, 65535, 65535, 0, 1), ('Secret', 253, 0, 64, 64, 0, 1), ('Active', 2, 0, 6, 6, 0, 1), ('MailQuota', 2, 0, 6, 6, 0, 1), ('Priv', 2, 0, 6, 6, 0, 1), ('Updated', 7, 14, 14, 14, 0, 0), ('AcctUpdate', 2, 0, 6, 6, 0, 1), ('RefNo', 3, 0, 11, 11, 0, 1), ('MailboxHash', 253, 0, 32, 32, 0, 1))
>>> r.fetch_row()
(None, None, 'Andy', 'adustman', '', None, None, None, None, None, '19990312021455', None, None, None)
>>> r.fetch_row()
(None, None, 'Ed Landa', 'elanda', '', 'elanda@beavis.comstar.net', None, None, None, None, '19990312022659', None, None, None)
>>> r.fetch_row()
>>>

Notes: NULL values represented by Python None object. fetch_row() returns
None at the end of the query set, which doesn't print. Conversion of data
types will be done in a Python wrapper module. Need to figure out a way
to read a fixed number of rows without having to twiddle with the global
interpreter lock all the time. Not a big problem if store_result() has
been used, but is trickier if use_result() was used.
1999-03-12 07:38:17 +00:00
adustman
638b154e72 A home-made mysql interface for Python so I can learn the API. It's almost
sorta functional. The problem with the existing interface (minor) is that
it's for 3.21 mysql. Not a huge problem, but it doesn't seem to have a stable
maintainer at the moment either.

Tommorrow I work on result objects so I can get queries done and stuff.

Python 1.5.2b2 (#1, Feb 18 1999, 18:20:08)  [GCC egcs-2.90.29 980515 (egcs-1.0.3 re on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import _mysql
>>> dir(_mysql)
['__doc__', '__file__', '__name__', 'connect', 'error', 'escape', 'get_client_info']
>>> _mysql.get_client_info()
'3.22.19a'
>>> c=_mysql.connect(passwd='foobar')
>>> dir(c)
['affected_rows', 'closed', 'dump_debug_info', 'errno', 'error', 'get_host_info', 'get_proto_info', 'get_server_info', 'info', 'open']
>>> c
<open connection to 'localhost' at 80ddf50>
>>> c.get_server_info()
'3.22.19a'
>>>
1999-03-11 05:38:47 +00:00