Skip to content

Commit a8cb3e7

Browse files
author
andrew.kuchling
committed
Add an item; better crediting; fix error in SQL example; minor edits
git-svn-id: http://svn.python.org/projects/python/trunk@45407 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent c68a7a2 commit a8cb3e7

1 file changed

Lines changed: 29 additions & 32 deletions

File tree

Doc/whatsnew/whatsnew25.tex

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
\usepackage{distutils}
33
% $Id$
44

5-
% Fix XXX comments
5+
% Writing context managers
66
% The easy_install stuff
77
% Stateful codec changes
8-
% cProfile
8+
% Fix XXX comments
99
% Count up the patches and bugs
1010

1111
\title{What's New in Python 2.5}
@@ -1400,7 +1400,8 @@ \subsection{The ElementTree package}
14001400
%======================================================================
14011401
\subsection{The hashlib package}
14021402

1403-
A new \module{hashlib} module has been added to replace the
1403+
A new \module{hashlib} module, written by Gregory P. Smith,
1404+
has been added to replace the
14041405
\module{md5} and \module{sha} modules. \module{hashlib} adds support
14051406
for additional secure hashes (SHA-224, SHA-256, SHA-384, and SHA-512).
14061407
When available, the module uses OpenSSL for fast platform optimized
@@ -1443,26 +1444,25 @@ \subsection{The hashlib package}
14431444
return the digest value as a binary string or a string of hex digits,
14441445
and \method{copy()} returns a new hashing object with the same digest state.
14451446

1446-
This module was contributed by Gregory P. Smith.
1447-
14481447

14491448
%======================================================================
14501449
\subsection{The sqlite3 package}
14511450

14521451
The pysqlite module (\url{http://www.pysqlite.org}), a wrapper for the
14531452
SQLite embedded database, has been added to the standard library under
1454-
the package name \module{sqlite3}. SQLite is a C library that
1455-
provides a SQL-language database that stores data in disk files
1456-
without requiring a separate server process. pysqlite was written by
1457-
Gerhard H\"aring, and provides a SQL interface that complies with the
1458-
DB-API 2.0 specification described by \pep{249}. This means that it
1459-
should be possible to write the first version of your applications
1460-
using SQLite for data storage and, if switching to a larger database
1461-
such as PostgreSQL or Oracle is necessary, the switch should be
1462-
relatively easy.
1453+
the package name \module{sqlite3}.
1454+
1455+
SQLite is a C library that provides a SQL-language database that
1456+
stores data in disk files without requiring a separate server process.
1457+
pysqlite was written by Gerhard H\"aring and provides a SQL interface
1458+
compliant with the DB-API 2.0 specification described by
1459+
\pep{249}. This means that it should be possible to write the first
1460+
version of your applications using SQLite for data storage. If
1461+
switching to a larger database such as PostgreSQL or Oracle is
1462+
later necessary, the switch should be relatively easy.
14631463

14641464
If you're compiling the Python source yourself, note that the source
1465-
tree doesn't include the SQLite code itself, only the wrapper module.
1465+
tree doesn't include the SQLite code, only the wrapper module.
14661466
You'll need to have the SQLite libraries and headers installed before
14671467
compiling Python, and the build process will compile the module when
14681468
the necessary headers are available.
@@ -1491,17 +1491,18 @@ \subsection{The sqlite3 package}
14911491
14921492
# Insert a row of data
14931493
c.execute("""insert into stocks
1494-
values ('2006-01-05','BUY','RHAT',100, 35.14)""")
1494+
values ('2006-01-05','BUY','RHAT',100,35.14)""")
14951495
\end{verbatim}
14961496

1497-
Usually your SQL queries will need to reflect the value of Python
1497+
Usually your SQL operations will need to use values from Python
14981498
variables. You shouldn't assemble your query using Python's string
14991499
operations because doing so is insecure; it makes your program
1500-
vulnerable to what's called an SQL injection attack. Instead, use
1501-
SQLite's parameter substitution, putting \samp{?} as a placeholder
1502-
wherever you want to use a value, and then provide a tuple of values
1503-
as the second argument to the cursor's \method{execute()} method. For
1504-
example:
1500+
vulnerable to an SQL injection attack.
1501+
1502+
Instead, use SQLite's parameter substitution. Put \samp{?} as a
1503+
placeholder wherever you want to use a value, and then provide a tuple
1504+
of values as the second argument to the cursor's \method{execute()}
1505+
method. For example:
15051506

15061507
\begin{verbatim}
15071508
# Never do this -- insecure!
@@ -1510,7 +1511,7 @@ \subsection{The sqlite3 package}
15101511
15111512
# Do this instead
15121513
t = (symbol,)
1513-
c.execute("... where symbol = '?'", t)
1514+
c.execute('select * from stocks where symbol=?', ('IBM',))
15141515
15151516
# Larger example
15161517
for t in (('2006-03-28', 'BUY', 'IBM', 1000, 45.00),
@@ -1540,15 +1541,6 @@ \subsection{The sqlite3 package}
15401541
>>>
15411542
\end{verbatim}
15421543

1543-
You should also use parameter substitution with SELECT statements:
1544-
1545-
\begin{verbatim}
1546-
>>> c.execute('select * from stocks where symbol=?', ('IBM',))
1547-
>>> print c.fetchall()
1548-
[(u'2006-03-28', u'BUY', u'IBM', 1000, 45.0),
1549-
(u'2006-04-06', u'SELL', u'IBM', 500, 53.0)]
1550-
\end{verbatim}
1551-
15521544
For more information about the SQL dialect supported by SQLite, see
15531545
\url{http://www.sqlite.org}.
15541546

@@ -1625,6 +1617,7 @@ \section{Build and C API Changes}
16251617
new set, \cfunction{PySet_Add()} and \cfunction{PySet_Discard()} to
16261618
add and remove elements, and \cfunction{PySet_Contains} and
16271619
\cfunction{PySet_Size} to examine the set's state.
1620+
(Contributed by Raymond Hettinger.)
16281621

16291622
\item C code can now obtain information about the exact revision
16301623
of the Python interpreter by calling the
@@ -1633,6 +1626,10 @@ \section{Build and C API Changes}
16331626
\code{"trunk:45355:45356M, Apr 13 2006, 07:42:19"}.
16341627
(Contributed by Barry Warsaw.)
16351628

1629+
\item The CPython interpreter is still written in C, but
1630+
the code can now be compiled with a {\Cpp} compiler without errors.
1631+
(Implemented by Anthony Baxter, Martin von~L\"owis, Skip Montanaro.)
1632+
16361633
\item The \cfunction{PyRange_New()} function was removed. It was
16371634
never documented, never used in the core code, and had dangerously lax
16381635
error checking.

0 commit comments

Comments
 (0)