Skip to content

Commit b4b3d0f

Browse files
author
Geert Vanderkelen
committed
Merge branch 'WL7716' into develop
2 parents e22f398 + d889f08 commit b4b3d0f

File tree

132 files changed

+38602
-2
lines changed

Some content is hidden

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

132 files changed

+38602
-2
lines changed

.gitignore

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

CHANGES.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
================================================
2+
MySQL Connector/Python - 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+
12+
v2.0.0a1
13+
========
14+
15+
Released on (not yet released)
16+
17+
* (features + bug fixes)
18+
19+

LICENSE.txt

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

MANIFEST.in

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
include README.txt
2+
include LICENSE.txt
3+
include CHANGES.txt
4+
include setup.py
5+
include setupinfo.py
6+
include version.py
7+
include unittests.py
8+
include MANIFEST.in
9+
10+
include python2/__init__.py
11+
recursive-include python2/examples *.py
12+
recursive-include python2/mysql *.py
13+
14+
include python3/__init__.py
15+
recursive-include python3/mysql *.py
16+
recursive-include python3/examples *.py
17+
18+
include python23/__init__.py
19+
recursive-include python23/django *.py
20+
recursive-include python23/fabric *.py
21+
recursive-include python23/tests23 *.py
22+
23+
recursive-include tests *.py *.csv pylint*.rc *.pem
24+
25+
include docs/README_DOCS.txt
26+

README.txt

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

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+

python2/__init__.py

Whitespace-only changes.

python2/examples/__init__.py

Whitespace-only changes.

python2/examples/client.py

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
# MySQL Connector/Python - MySQL driver written in Python.
5+
# Copyright (c) 2009, 2013, 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+
Simple CLI using the Connector/Python. It does not take arguments so
29+
you'll need to set the proper login information manually.
30+
31+
Example output:
32+
33+
$ ./client.py
34+
Welcome to MySQL Python CLI.
35+
Your MySQL connection ID is 21.
36+
Server version: 5.0.62-enterprise-gpl
37+
38+
Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
39+
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
40+
Type "help", "copyright", "credits" or "license" for more information.
41+
(MySQLConsole)
42+
>>> show tables;
43+
1046 (3D000): No database selected
44+
>>> use test;
45+
>>> show tables;
46+
>>> create table t1 (id int);
47+
>>> show tables;
48+
(u't1')
49+
"""
50+
51+
from __future__ import print_function
52+
53+
import sys
54+
import os
55+
import readline
56+
import code
57+
import atexit
58+
import re
59+
60+
# We're actually just a demo and supposed to run in the source directory.
61+
sys.path.append('.')
62+
63+
import mysql.connector
64+
65+
class MySQLConsole(code.InteractiveConsole):
66+
mysql = None
67+
regexp = {}
68+
69+
def __init__(self, mysql, locals=None, filename="<console>",
70+
histfile=os.path.expanduser("~/.mysql_history")):
71+
code.InteractiveConsole.__init__(self)
72+
self.init_history(histfile)
73+
self.mysql = mysql
74+
75+
self.regexp['USE'] = re.compile('USE (\w*)', re.IGNORECASE)
76+
77+
def init_history(self, histfile):
78+
readline.parse_and_bind("tab: complete")
79+
if hasattr(readline, "read_history_file"):
80+
try:
81+
readline.read_history_file(histfile)
82+
except IOError:
83+
pass
84+
atexit.register(self.save_history, histfile)
85+
86+
def save_history(self, histfile):
87+
readline.write_history_file(histfile)
88+
89+
def send_query(self, line):
90+
rows = ()
91+
try:
92+
cursor = self.mysql.cursor()
93+
cursor.execute(line)
94+
except mysql.connector.errors.Error as e:
95+
print(e.errmsglong)
96+
return
97+
98+
try:
99+
rows = cursor.fetchall()
100+
for row in rows:
101+
print(row)
102+
except:
103+
pass
104+
105+
def _do_use(db):
106+
try:
107+
my.cmd_init_db(db)
108+
except mysql.connector.errors.InterfaceError as e:
109+
print(e)
110+
111+
def push(self, line):
112+
try:
113+
res = self.regexp['USE'].findall(line)
114+
db = res[0]
115+
self._do_use(db)
116+
except:
117+
pass
118+
self.send_query(line)
119+
code.InteractiveConsole(self, line)
120+
121+
122+
if __name__ == '__main__':
123+
124+
print("Welcome to MySQL Python CLI.")
125+
126+
try:
127+
db = mysql.connector.Connect(unix_socket='/tmp/mysql.sock', user='root', password='')
128+
except mysql.connector.errors.InterfaceError as e:
129+
print(e)
130+
sys.exit(1)
131+
132+
console = MySQLConsole(db)
133+
myconnpy_version = "%s-%s" % (
134+
'.'.join(map(str,mysql.connector.__version__[0:3])),
135+
mysql.connector.__version__[3])
136+
137+
print("Your MySQL connection ID is %d." % (db.get_server_threadid()))
138+
print("Server version: %s" % (db.get_server_info()))
139+
print("MySQL Connector/Python v%s" % (myconnpy_version))
140+
print()
141+
142+
console.interact()
143+
144+

python2/examples/config.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# MySQL Connector/Python - MySQL driver written in Python.
4+
# Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
5+
6+
# MySQL Connector/Python is licensed under the terms of the GPLv2
7+
# <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
8+
# MySQL Connectors. There are special exceptions to the terms and
9+
# conditions of the GPLv2 as it is applied to this software, see the
10+
# FOSS License Exception
11+
# <http://www.mysql.com/about/legal/licensing/foss-exception.html>.
12+
#
13+
# This program is free software; you can redistribute it and/or modify
14+
# it under the terms of the GNU General Public License as published by
15+
# the Free Software Foundation.
16+
#
17+
# This program is distributed in the hope that it will be useful,
18+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
# GNU General Public License for more details.
21+
#
22+
# You should have received a copy of the GNU General Public License
23+
# along with this program; if not, write to the Free Software
24+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25+
26+
class Config(object):
27+
"""Configure me so examples work
28+
29+
Use me like this:
30+
31+
mysql.connector.Connect(**Config.dbinfo())
32+
"""
33+
34+
HOST = 'localhost'
35+
DATABASE = 'test'
36+
USER = ''
37+
PASSWORD = ''
38+
PORT = 3306
39+
40+
CHARSET = 'utf8'
41+
UNICODE = True
42+
WARNINGS = True
43+
44+
@classmethod
45+
def dbinfo(cls):
46+
return {
47+
'host': cls.HOST,
48+
'port': cls.PORT,
49+
'database': cls.DATABASE,
50+
'user': cls.USER,
51+
'password': cls.PASSWORD,
52+
'charset': cls.CHARSET,
53+
'use_unicode': cls.UNICODE,
54+
'get_warnings': cls.WARNINGS,
55+
}
56+

0 commit comments

Comments
 (0)