Skip to content

Commit 89ab0e6

Browse files
author
Geert Vanderkelen
committed
Merge branch 'release-2.0.0'
2 parents e22f398 + 6063340 commit 89ab0e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+28241
-2
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,10 @@
55
commit.txt
66
*.patch
77
*.diff
8-
8+
dist/
9+
build/
10+
MANIFEST
11+
cpy_server*/
12+
*_output.txt
13+
tests_*.log
14+
dev*.py

CHANGES.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
====================================================
2+
MySQL Connector/Python 2.0 - Release Notes & Changes
3+
====================================================
4+
5+
MySQL Connector/Python
6+
Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
7+
8+
Full release notes:
9+
http://dev.mysql.com/doc/relnotes/connector-python/en/
10+
11+
v2.0.0a1
12+
========
13+
14+
- BUG19207922: Fix fetching multiple results when executing procedure
15+
- BUG19184025: Fix results containing NULL
16+
- BUG19169990: Fix sending/receiving using compressed connection
17+
- BUG18956789: Fix Django TimeField 00:00:00 converting to MySQL NULL
18+
- WL7228: Allow Connector/Python to use MySQL option files
19+
- BUG18843153: Fix Django to check connection on each request
20+
- WL7937: Allow LOAD DATA LOCAL INFILE by default
21+
- BUG18742429: Fix prepared statements returning lots of columns
22+
- BUG18814880: Fix stopping mysqld running unit tests on Windows
23+
- WL7292: Add cursors returning dict and namedtuple as rows
24+
- WL7462: Consolidate Python v2 and v3 code
25+
- WL7716: Move commercial files and distribution to CPYINT
26+

LICENSE.txt

Lines changed: 347 additions & 0 deletions
Large diffs are not rendered by default.

MANIFEST.in

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
include README.txt
2+
include LICENSE.txt
3+
include CHANGES.txt
4+
include setup.py
5+
include setupinfo.py
6+
include unittests.py
7+
include MANIFEST.in
8+
9+
recursive-include examples *.py
10+
recursive-include lib *.py
11+
recursive-include tests *.py *.csv *.pem *.cnf
12+
13+
include docs/README_DOCS.txt
14+

README.txt

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
==========================
2+
MySQL Connector/Python 2.0
3+
==========================
4+
5+
MySQL Connector/Python
6+
Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
7+
8+
License information can be found in the LICENSE.txt file.
9+
10+
11+
Documentation & Examples
12+
========================
13+
14+
Documentation for all Connector/Python versions can be found online here:
15+
16+
http://dev.mysql.com/doc/connector-python/en/index.html
17+
18+
The source distribution of Connector/Python also contains example scripts.
19+
They can be found in the examples/ directory.
20+
21+
22+
License
23+
=======
24+
25+
This is a release of MySQL Connector/Python, Oracle's dual-
26+
license Python Driver for MySQL. For the avoidance of
27+
doubt, this particular copy of the software is released
28+
under the version 2 of the GNU General Public License.
29+
MySQL Connector/Python is brought to you by Oracle.
30+
31+
Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
32+
33+
License information can be found in the LICENSE.txt file.
34+
35+
MySQL FOSS License Exception
36+
We want free and open source software applications under
37+
certain licenses to be able to use the GPL-licensed MySQL
38+
Connector/Python (specified GPL-licensed MySQL client libraries)
39+
despite the fact that not all such FOSS licenses are
40+
compatible with version 2 of the GNU General Public License.
41+
Therefore there are special exceptions to the terms and
42+
conditions of the GPLv2 as applied to these client libraries,
43+
which are identified and described in more detail in the
44+
FOSS License Exception at
45+
<http://www.mysql.com/about/legal/licensing/foss-exception.html>
46+
47+
This software is OSI Certified Open Source Software.
48+
OSI Certified is a certification mark of the Open Source Initiative.
49+
50+
This distribution may include materials developed by third
51+
parties. For license and attribution notices for these
52+
materials, please refer to the documentation that accompanies
53+
this distribution (see the "Licenses for Third-Party Components"
54+
appendix) or view the online documentation at
55+
<http://dev.mysql.com/doc/>
56+
A copy of the license/notices is also reproduced below.
57+
58+
GPLv2 Disclaimer
59+
For the avoidance of doubt, except that if any license choice
60+
other than GPL or LGPL is available it will apply instead,
61+
Oracle elects to use only the General Public License version 2
62+
(GPLv2) at this time for any software where a choice of GPL
63+
license versions is made available with the language indicating
64+
that GPLv2 or any later version may be used, or where a choice
65+
of which version of the GPL is applied is otherwise unspecified.
66+

cpyint

docs/README_DOCS.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The manual of MySQL Connector/Python is available online here:
2+
3+
http://dev.mysql.com/doc/connector-python/en/index.html
4+
5+
6+
It is also available for download in various formats here:
7+
8+
http://dev.mysql.com/doc/index-connectors.html
9+

examples/__init__.py

Whitespace-only changes.

examples/dates.py

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
# MySQL Connector/Python - MySQL driver written in Python.
5+
# Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
6+
7+
# MySQL Connector/Python is licensed under the terms of the GPLv2
8+
# <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
9+
# MySQL Connectors. There are special exceptions to the terms and
10+
# conditions of the GPLv2 as it is applied to this software, see the
11+
# FOSS License Exception
12+
# <http://www.mysql.com/about/legal/licensing/foss-exception.html>.
13+
#
14+
# This program is free software; you can redistribute it and/or modify
15+
# it under the terms of the GNU General Public License as published by
16+
# the Free Software Foundation.
17+
#
18+
# This program is distributed in the hope that it will be useful,
19+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+
# GNU General Public License for more details.
22+
#
23+
# You should have received a copy of the GNU General Public License
24+
# along with this program; if not, write to the Free Software
25+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26+
27+
"""
28+
29+
Example using MySQL Connector/Python showing:
30+
* How to get datetime, date and time types
31+
* Shows also invalid dates returned and handled
32+
* Force sql_mode to be not set for the active session
33+
34+
"""
35+
36+
from datetime import datetime
37+
38+
import mysql.connector
39+
40+
41+
# Note that by default MySQL takes invalid timestamps. This is for
42+
# backward compatibility. As of 5.0, use sql modes NO_ZERO_IN_DATE,NO_ZERO_DATE
43+
# to prevent this.
44+
_adate = datetime(1977, 6, 14, 21, 10, 00)
45+
DATA = [
46+
(_adate.date(), _adate, _adate.time()),
47+
('0000-00-00', '0000-00-00 00:00:00', '00:00:00'),
48+
('1000-00-00', '9999-00-00 00:00:00', '00:00:00'),
49+
]
50+
51+
def main(config):
52+
output = []
53+
db = mysql.connector.Connect(**config)
54+
cursor = db.cursor()
55+
56+
tbl = 'myconnpy_dates'
57+
58+
cursor.execute('SET sql_mode = ""')
59+
60+
# Drop table if exists, and create it new
61+
stmt_drop = "DROP TABLE IF EXISTS {0}".format(tbl)
62+
cursor.execute(stmt_drop)
63+
64+
stmt_create = (
65+
"CREATE TABLE {0} ( "
66+
" `id` tinyint(4) NOT NULL AUTO_INCREMENT, "
67+
" `c1` date DEFAULT NULL, "
68+
" `c2` datetime NOT NULL, "
69+
" `c3` time DEFAULT NULL, "
70+
" `changed` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP "
71+
" ON UPDATE CURRENT_TIMESTAMP, "
72+
"PRIMARY KEY (`id`))"
73+
).format(tbl)
74+
cursor.execute(stmt_create)
75+
76+
# not using executemany to handle errors better
77+
stmt_insert = ("INSERT INTO {0} (c1,c2,c3) VALUES "
78+
"(%s,%s,%s)".format(tbl))
79+
for data in DATA:
80+
try:
81+
cursor.execute(stmt_insert, data)
82+
except (mysql.connector.errors.Error, TypeError) as exc:
83+
output.append("Failed inserting {0}\nError: {1}\n".format(
84+
data, exc))
85+
raise
86+
87+
# Read the names again and print them
88+
stmt_select = "SELECT * FROM {0} ORDER BY id".format(tbl)
89+
cursor.execute(stmt_select)
90+
91+
for row in cursor.fetchall():
92+
output.append("%3s | %10s | %19s | %8s |" % (
93+
row[0],
94+
row[1],
95+
row[2],
96+
row[3],
97+
))
98+
99+
# Cleaning up, dropping the table again
100+
cursor.execute(stmt_drop)
101+
102+
cursor.close()
103+
db.close()
104+
return output
105+
106+
107+
if __name__ == '__main__':
108+
#
109+
# Configure MySQL login and database to use in config.py
110+
#
111+
config = {
112+
'host': 'localhost',
113+
'port': 3306,
114+
'database': 'test',
115+
'user': 'root',
116+
'password': '',
117+
'charset': 'utf8',
118+
'use_unicode': True,
119+
'get_warnings': True,
120+
}
121+
122+
out = main(config)
123+
print('\n'.join(out))

examples/engines.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
# MySQL Connector/Python - MySQL driver written in Python.
5+
# Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
6+
7+
# MySQL Connector/Python is licensed under the terms of the GPLv2
8+
# <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
9+
# MySQL Connectors. There are special exceptions to the terms and
10+
# conditions of the GPLv2 as it is applied to this software, see the
11+
# FOSS License Exception
12+
# <http://www.mysql.com/about/legal/licensing/foss-exception.html>.
13+
#
14+
# This program is free software; you can redistribute it and/or modify
15+
# it under the terms of the GNU General Public License as published by
16+
# the Free Software Foundation.
17+
#
18+
# This program is distributed in the hope that it will be useful,
19+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+
# GNU General Public License for more details.
22+
#
23+
# You should have received a copy of the GNU General Public License
24+
# along with this program; if not, write to the Free Software
25+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26+
27+
"""
28+
29+
Example using MySQL Connector/Python showing:
30+
* that show engines works..
31+
32+
"""
33+
34+
import sys, os
35+
36+
import mysql.connector
37+
38+
def main(config):
39+
output = []
40+
db = mysql.connector.Connect(**config)
41+
cursor = db.cursor()
42+
43+
# Select it again and show it
44+
stmt_select = "SHOW ENGINES"
45+
cursor.execute(stmt_select)
46+
rows = cursor.fetchall()
47+
48+
for row in rows:
49+
output.append(repr(row))
50+
51+
db.close()
52+
return output
53+
54+
if __name__ == '__main__':
55+
56+
config = {
57+
'host': 'localhost',
58+
'port': 3306,
59+
'database': 'test',
60+
'user': 'root',
61+
'password': '',
62+
'charset': 'utf8',
63+
'use_unicode': True,
64+
'get_warnings': True,
65+
}
66+
67+
out = main(config)
68+
print('\n'.join(out))

0 commit comments

Comments
 (0)