Original copyright notices from the top of the mySQLmodule-0.1.4 ---------------------------------------------------------------- /* An interface to the mySQL database system for Python Copyright (C) 1997 Joseph Skinner Query cursor code and some modifications Copyright (C) 1997 James Henstridge Based on mSQLmodule which was by the following people: Portions copyright (C) 1995 Thawte Consulting, cc (Those portions covered by the next copyright notice) Portions copyright (C) 1994 Anthony Baxter. ******************************************************************* Ported to mySQL Skinner (joe@earthlight.co.nz) Janurary 1997 -- STATUS : BETA --VERSION 0.1.0 - converted source - added support for some of the types not included in mSQL - added support for return of auto_increment values an auto_increment value is returned as a result from an insert VERSION 0.1.2 (1997-04-02) - added support for varchar - added support for username and passwords VERSION 0.1.4 (1997-09-09) - added decimal and float types - added a query cursor. (Mainly to support mysqldb - the Python DB API module for MySQL) See New file. - changed behavior so that currently unhandled types are returned as strings, so that the python programmer can figure out what to do with them. -- TODO - support timestamps - support all unsupported mysql types */ /* This mSQLmodule copyright (it only applies to those sections): ****************************************************** * * Based on a prior work by Anthony Baxter * Updated, fixed and extended by David Gibson working for * Thawte Consulting cc, South Africa. * * Copyright 1995 Thawte Consulting cc * Portions copyright (C) 1994 Anthony Baxter. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this source file to use, copy, modify, merge, or publish it * subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or in any new file that contains a substantial portion of * this file. * * THE AUTHOR MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF * THE SOFTWARE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT * EXPRESS OR IMPLIED WARRANTY. THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NON-INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE * AUTHOR BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE, STRICT LIABILITY OR * ANY OTHER ACTION ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * ****************************************************** mSQLmodule ChangeLog:- (slightly mangled by msql2mysql) Modified by David Gibson December 1995 - listdbs and listtables now return a list of strings - new Python naming conventions introduced - queries now return data types in native Python format (String,Float,Int) - solved spurious 'function requires at least one argument' error: old getargs would not handle optional arguments. ParseTuple is being used now. (so method table has got 1's in now) (old Parse routine still needed for subscript handling) - mysql_free_result now called after query! - assignment to subscript trapped correctly. Ditto len() - added DbType to the module dictionary - mySQL.error object introduced ****************************************************** */ ----- Original New file from mySQLmodule --------------------------- Release 0.1.4 1997-09-09 Added Support for the following types float -- from Mitch Chapman decimal -- me (I had to do something in this release :-) ) Added a connect patch from Giles Francis Hall I just thought you might want to have this small piece of code which traps an connect() error. I was wondering what was happening with my programs when they the SQL server was down yet things seemed to go happily along their way returning empty data sets ;) ... ***** if(!(mysql_connect(&newhandle, dbname, dbuser, dbpass))) { PyErr_SetString(mySQLError, "connect(): could not connect to MySQL"); return NULL; } Added Support for the python dbi standard from James Henstridge These modifications by James Henstridge : This release adds an extra object called a querycursor. The querycursor object is used to look at a large result from a query. It doesn't convert the complete result to a list, only converting the sections asked for. They are created as a result from the querycursor function. ie curs = connection.querycursor('select * from table') These objects have the following methods: fields() -- Similar output to connection.listfields(). insert_id() -- Returns the insert ID of the query. fetchall() -- Fetch a list of all the remaining records. fetchone() -- Fetch the next record. fetchmany(num) -- Fetch a list of at most num records. seek(pos) -- set the cursor position in the result. eof() -- returns true if there are no more records. numrows() -- returns the number of rows in the result. numfields() -- returns the number of fields in the result. affectedrows() -- returns the number of affected rows. -1 for select queries If the query doesn't return a result, all but the last method will raise an exception. As a change to the behavior of the old functions, instead of not returning `unhandled' field values, they are returned as strings, in the hope that the python programmer will be able to find some sensible way of using them. Also included in this distribution is mysqldb.py, which is a Python DB API compliant interface to MySQL databases, written as a frontend to mySQLmodule. Mysqldb should be used for new programs, since it makes them more portable across different databases. More information on this specification can be found at http://www.python.org/sigs/db-sig/DatabaseAPI.html An example module mysqlshelve is included which uses mysqldb to implement an object similar to Shelf, which stores the information in a MySQL table. Release 0.1.3 1997-04-23 This code has been tested on a linux box using linux 2.1.55 libc6 and mysql 3.20.29 Bug Fixes Fixes for my silly typos in timedate handling provided by Karsten Thygesen New commands It includes the following new functionality. create(db_name) create a new database drop(db_name) drop a database reload() reload the mysql tables shutdown() shutdown mysql Release 0.1.2 1997-04-03 New In this Release Support for new mysql types varchar blobs time date timedate timestamp Support for Username and Passwords authentification is handled as part of the connect option ie import mySQL db = mySQL.connect() where options can be either nothing -- connect() hostname -- connect('localhost') hostname, username -- connect('localhost', 'fred') hostname, username, password -- connect('localhost, 'fred','green') IMPORTANT The support for date and time will not work with earlier versions of mysql which did not support these functions. Therefore these may be disabled by changing the #define #define INCLUDE_DATE_TIME_SUPPORT 1 to #undef INCLUDE_DATE_TIME_SUPPORT at the top the file. ----- Original Credits file from mySQLmodule ------------------------ All those people who have put word into the mySQL module Monty -- lots of code and suggestions James Henstridge ) -- the new Python DB extensions Mitch Chapman -- float support Giles Francis Hall -- fix for connect bug The orginal authors of the mSQL module