1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
|
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 <joe@earthlink.co.nz>
Query cursor code and some modifications
Copyright (C) 1997 James Henstridge <james@daa.com.au>
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 <mchapman@OhioEE.com>
decimal -- me (I had to do something in this release :-) )
Added a connect patch from Giles Francis Hall <ghall@interaccess.com>
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 <james@daa.com.au>
These modifications by James Henstridge <james@daa.com.au>:
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 <karthy@kom.auc.dk>
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(<OPTIONS>)
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 <james@daa.com.au>) -- the new Python DB extensions
Mitch Chapman <mchapman@OhioEE.com> -- float support
Giles Francis Hall <ghall@interaccess.com> -- fix for connect bug
The orginal authors of the mSQL module
|