It's more than a year since python 3 was released, but there aren't any lib...
I searched but found nothing.. (actually I found mypysql, but it doesn't compile
for win)
every time someone says that want use mysql in py3k he receives answer: "do
you really need python 3? use python 2.6"
thats NOT a solution, just easiest workaround...
some time I used mysql.php (self-made php script) it accepts post query and
returns xml result (it can be used in any language that have http and xml
support)
but this is just another workaround...
I got tired of these workarounds and so I ported MySQL-python-1.2.3 to python
3, it works fine and passes both tests (dbapi20 and capabilities) without any
errors... (I little modified tests to work in py3k)
WindowsError: The system cannot find the file specified
I'll figure this out sooner or later. Regardless, thank you for your awesome
work, it's greatly appreciated. I didn't want to start a huge project in
Python2 when really, things should be moving towards 3
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It was because I didn't have MySQL installed on my local machine.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2010-09-30
PS C:\MySQL-python-1.2.3-py3k> python
Python 3.1.2 (r312:79149, Mar 20 2010, 22:55:39) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
PS C:\MySQL-python-1.2.3-py3k> mysql -h localhost -u root -p
Enter password: *********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1692
Server version: 5.5.5-m3 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> exit
Bye
PS C:\MySQL-python-1.2.3-py3k> python setup.py install
Traceback (most recent call last):
File "setup.py", line 15, in <module>
metadata, options = get_config()
File "C:\MySQL-python-1.2.3-py3k\setup_windows.py", line 7, in get_config
serverKey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, options['registry_key'])
WindowsError: [Error 2] The system cannot find the file specified
PS C:\MySQL-python-1.2.3-py3k>
obviously i have mysql installed, get this error....
would be great if this worked...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2010-09-30
just tried it on another machine with a non-beta version of mysql, same
error...
this is win64 if that helps.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2010-10-01
You gotta edit site.cfg and set the registry key appropriately, depending on
what version of MySQL you have installed.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2010-10-03
I can get this working with mysql 5.1 with python 3.1.2 32-bit on windows xp
sp3 32-bit with visual studio c++ 2008 express.
I can not get this working with mysql 5.1 64-bit with python 3.1.2 64-bit on
windows 7 64-bit with visual studio c++ 2008 express.
has this been tested on windows 7, or on any windows 64-bit platform, any
luck? hints?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2010-10-03
A binary for windows 7 64-bit and python 3.1.2 64-bit would be amazingly
appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've never used Mac, so I don't know, but looks like you have compiled it for
wrong architecture... or you haven't compiled it...
look at site.cfg and change registry_key = SOFTWARE\MySQL AB\MySQL Server
5.0 on registry_key = SOFTWARE\MySQL AB\MySQL Server 5.1 -- depends on your
MySQL version
I think Mac doesn't have registry, or does it?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Win 7 x64, MySQL 5.5, Python 3.1, VisualC++ 2008 Express with Windows SDK with
x64 libraries:
I have all the env variables for python, visual c++ but no luck...this is what
i get
-1.2.3-py3k>python setup.py install
running install
install_dir C:\Python31\Lib\site-packages\
running bdist_egg
running egg_info
writing MySQL_python.egg-info\PKG-INFO
writing top-level names to MySQL_python.egg-info\top_level.txt
writing dependency_links to MySQL_python.egg-info\dependency_links.txt
reading manifest file 'MySQL_python.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
writing manifest file 'MySQL_python.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
copying MySQLdb\release.py -> build\lib.win-amd64-3.1\MySQLdb
running build_ext
building '_mysql' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe /c /nolog
o /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3
"-IC:\Program Files\MySQL\MySQL Server 5.5\include" -IC:\Python31\include -IC:\
Python31\PC /Tc_mysql.c /Fobuild\temp.win-amd64-3.1\Release\_mysql.obj /Zl
_mysql.c
C:\Program Files\MySQL\MySQL Server 5.5\include\config-win.h(24) : warning C4005
: '_WIN32_WINNT' : macro redefinition
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\sdkddkver.h(197) :
see previous definition of '_WIN32_WINNT'
C:\Program Files\MySQL\MySQL Server 5.5\include\config-win.h(203) : warning C400
5: 'SIZEOF_OFF_T' : macro redefinition
c:\python31\include\pyconfig.h(343) : see previous definition of 'SIZEOF
_OFF_T'
C:\Program Files\MySQL\MySQL Server 5.5\include\config-win.h(301) : warning C400
5: 'HAVE_STDDEF_H' : macro redefinition
c:\python31\include\pyconfig.h(682) : see previous definition of 'HAVE_S
TDDEF_H'
_mysql.c(242) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', poss
ible loss of data
_mysql.c(267) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', poss
ible loss of data
_mysql.c(394) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to
'int', possible loss of data
_mysql.c(1004) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', pos
sible loss of data
_mysql.c(1107) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', pos
sible loss of data
_mysql.c(1337) : warning C4267: '=' : conversion from 'size_t' to 'int', possibl
e loss of data
_mysql.c(1339) : warning C4267: '=' : conversion from 'size_t' to 'int', possibl
e loss of data
_mysql.c(1383) : warning C4267: '=' : conversion from 'size_t' to 'int', possibl
e loss of data
_mysql.c(1385) : warning C4267: '=' : conversion from 'size_t' to 'int', possibl
e loss of data
_mysql.c(2139) : warning C4244: 'function' : conversion from '__int64' to 'long'
, possible loss of data
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\link.exe /DLL /n
ologo /INCREMENTAL:NO "/LIBPATH:C:\Program Files\MySQL\MySQL Server 5.5\lib\opt"
/LIBPATH:C:\Python31\libs /LIBPATH:C:\Python31\PCbuild\amd64 kernel32.lib advap
i32.lib wsock32.lib mysqlclient.lib /EXPORT:PyInit__mysql build\temp.win-amd64-3
.1\Release\_mysql.obj /OUT:build\lib.win-amd64-3.1\_mysql.pyd /IMPLIB:build\temp
.win-amd64-3.1\Release\_mysql.lib /MANIFESTFILE:build\temp.win-amd64-3.1\Release
\_mysql.pyd.manifest
LINK : fatal error LNK1181: cannot open input file 'mysqlclient.lib'
error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64
\link.exe"' failed with exit status 1181
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Run win_buld.cmd (if python.exe isn't in PATH then edit and set path to it)
Enjoy
NOTE!
If you gen "error: Unable to find vcvarsall.bat"
then edit file "<path_to_python_dir>\Lib\distutils\msvc9compiler.py"
at line ~294 replace "VERSION = get_build_version()" with
"#VERSION = get_build_version()
VERSION = 10.0"
PS. this is for MS VS2010 to work...
if you encounter any problems you can try post here and i'll try to help if I
have time...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's more than a year since python 3 was released, but there aren't any lib...
I searched but found nothing.. (actually I found
mypysql, but it doesn't compile
for win)
every time someone says that want use mysql in py3k he receives answer: "do
you really need python 3? use python 2.6"
thats NOT a solution, just easiest workaround...
some time I used mysql.php (self-made php script) it accepts post query and
returns xml result (it can be used in any language that have http and xml
support)
but this is just another workaround...
I got tired of these workarounds and so I ported MySQL-python-1.2.3 to python
3, it works fine and passes both tests (dbapi20 and capabilities) without any
errors... (I little modified tests to work in py3k)
here it is MySQL-python-1.2.3-py3k
feel free to use but "This program comes with ABSOLUTELY NO WARRANTY"
I removed most of python 2 stuff so it's only for py3k
I tested it with python 3.1 and mysql 5.1 on win32 (it should work on any
platform where MySQL-python-1.2.3 works)
It should work and have same functionally like original MySQL-python-1.2.3 for
python 2
just remember it's py3k and some things are different...
files I edited:
MySQLdb__init__.py
MySQLdb\connections.py
MySQLdb\converters.py
MySQLdb\cursors.py
tests\capabilities.py
tests\dbapi20.py
tests\test_MySQLdb_capabilities.py
tests\test_MySQLdb_dbapi20.py
_mysql.c
_mysql_exceptions.py
setup.py
setup_common.py
setup_posix.py
setup_windows.py
site.cfg (only changed 5.0 to 5.1)
I didn't remove any files and didn't add others too...
this is open source so if you find a bug then fix it and upload code somewhere
and post link here..
anyone gotten this to work ?
me :D
you'll need distribute (it's
like setuptools)
then run:
thats all ;)
PS. sometimes you need run twice...
C:\Users\Jason\Downloads\MySQL-python-1.2.3-py3k\MySQL-
python-1.2.3-py3k>python setup.py install
Traceback (most recent call last):
File "setup.py", line 15, in <module>
metadata, options = get_config()
File "C:\Users\Jason\Downloads\MySQL-python-1.2.3-py3k\MySQL-
python-1.2.3-py3k\setup_windows.py", line 7, in get_config
serverKey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, options)
WindowsError: The system cannot find the file specified
I'll figure this out sooner or later. Regardless, thank you for your awesome
work, it's greatly appreciated. I didn't want to start a huge project in
Python2 when really, things should be moving towards 3
It was because I didn't have MySQL installed on my local machine.
PS C:\MySQL-python-1.2.3-py3k> python
obviously i have mysql installed, get this error....
would be great if this worked...
just tried it on another machine with a non-beta version of mysql, same
error...
this is win64 if that helps.
You gotta edit site.cfg and set the registry key appropriately, depending on
what version of MySQL you have installed.
I can get this working with mysql 5.1 with python 3.1.2 32-bit on windows xp
sp3 32-bit with visual studio c++ 2008 express.
I can not get this working with mysql 5.1 64-bit with python 3.1.2 64-bit on
windows 7 64-bit with visual studio c++ 2008 express.
has this been tested on windows 7, or on any windows 64-bit platform, any
luck? hints?
A binary for windows 7 64-bit and python 3.1.2 64-bit would be amazingly
appreciated.
I wasn't any problem with win7 x64
you were lucky: MySQL-python-1.2.3-py3.1-win-
amd64
Windows 7, VS 2010, MySQL 5.1, Python 3.1.2
thanks a million!
I had to set the following for Vista x64 in the site.cfg file:
registry_key = SOFTWARE\Wow6432Node\MySQL AB\MySQL Server 5.1
This got me a bit further but now I've got a missing header file when running
setup.py install:
_mysql.c(34) : fatal error C1083: Cannot open include file: 'config-win.h': No
such file or directory
Where do I get this file? Any ideas?
you need MySQL with source header files and that registry location points to
MySQL root dir where must be include and lib dirs...
you can download MySQL installation with these headers from
MySQL site
I am totally new to python, and since im using it in a academic manner I'm
lucky enough to be forced to use python3.
I managed to install the MySQL module, but when i try to include it in a file,
i get the following error:
I am using Mac Os X Snow Leopard. any ideas?
look at site.cfg and change
registry_key = SOFTWARE\MySQL AB\MySQL Server 5.0
on
registry_key = SOFTWARE\MySQL AB\MySQL Server 5.1
-- depends on your MySQL version
I've never used Mac, so I don't know, but looks like you have compiled it for
wrong architecture... or you haven't compiled it...
I think Mac doesn't have registry, or does it?
I used it with python 27. I used queries like curs.execute("select %s from
table", parameter), but now it doesn't work with 3.1. %s isn't converted.
yes, because in python 3 there are no %s format modifier, please read pyhton 3
manual ;)
now you have to do this way "select {!s} from table", param or "select {} from
table", param
Format Specification Mini-
Language
sorry previous link was mistake...
read this: Format String
Syntax
I`m having trouble installing this using:
Win 7 x64, MySQL 5.5, Python 3.1, VisualC++ 2008 Express with Windows SDK with
x64 libraries:
I have all the env variables for python, visual c++ but no luck...this is what
i get
ok, so i got it to work with MySQL 5.1
also if anyone is interested these instructions helped to remove some of the
errors i was getting:
http://www.fuyun.org/2009/12/install-mysql-for-python-on-
windows/
I got it to work mate...it`s just a matter of having some patience
and...wisdom ;)
Here is updated version for MySQL 5.5 (I think this will NOT work for MySQL <
5.5) and Python 3.2 (works on Python 3.1 too) MySQL-python-1.2.3-py3k-
mysql5.5-updated.zip
Tested on Win7 x64 with MS Visual Studio 2010 + WinSDK 7.1; Python 3.2 and
MySQL 5.5
It's never been so easy to compile it for windows ;)
Enjoy
NOTE!
If you gen "error: Unable to find vcvarsall.bat"
then edit file "<path_to_python_dir>\Lib\distutils\msvc9compiler.py"
at line ~294 replace "VERSION = get_build_version()" with
"#VERSION = get_build_version()
VERSION = 10.0"
PS. this is for MS VS2010 to work...
if you encounter any problems you can try post here and i'll try to help if I
have time...
sorry little typo in previous post.. download it here: MySQL-python-1.2.3
-py3k-mysql5.5-updated
PS. It's very bad that posts can be edited :(