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:
>setup.pyinstallrunninginstallinstall_dirH:\Python31\Lib\site-packages\
runningbdist_eggrunningegg_infowritingMySQL_python.egg-info\PKG-INFOwritingtop-levelnamestoMySQL_python.egg-info\top_level.txtwritingdependency_linkstoMySQL_python.egg-info\dependency_links.txtreadingmanifestfile'MySQL_python.egg-info\SOURCES.txt'readingmanifesttemplate'MANIFEST.in'warning:nofilesfoundmatching'MANIFEST'warning:nofilesfoundmatching'ChangeLog'warning:nofilesfoundmatching'GPL'writingmanifestfile'MySQL_python.egg-info\SOURCES.txt'installinglibrarycodetobuild\bdist.win-amd64\eggrunninginstall_librunningbuild_pycreatingbuildcreatingbuild\lib.win-amd64-3.1copying_mysql_exceptions.py->build\lib.win-amd64-3.1creatingbuild\lib.win-amd64-3.1\MySQLdbcopyingMySQLdb\__init__.py->build\lib.win-amd64-3.1\MySQLdbcopyingMySQLdb\converters.py->build\lib.win-amd64-3.1\MySQLdbcopyingMySQLdb\connections.py->build\lib.win-amd64-3.1\MySQLdbcopyingMySQLdb\cursors.py->build\lib.win-amd64-3.1\MySQLdbcopyingMySQLdb\release.py->build\lib.win-amd64-3.1\MySQLdbcopyingMySQLdb\times.py->build\lib.win-amd64-3.1\MySQLdbcreatingbuild\lib.win-amd64-3.1\MySQLdb\constantscopyingMySQLdb\constants\__init__.py->build\lib.win-amd64-3.1\MySQLdb\constantscopyingMySQLdb\constants\CR.py->build\lib.win-amd64-3.1\MySQLdb\constantscopyingMySQLdb\constants\FIELD_TYPE.py->build\lib.win-amd64-3.1\MySQLdb\constantscopyingMySQLdb\constants\ER.py->build\lib.win-amd64-3.1\MySQLdb\constantscopyingMySQLdb\constants\FLAG.py->build\lib.win-amd64-3.1\MySQLdb\constantscopyingMySQLdb\constants\REFRESH.py->build\lib.win-amd64-3.1\MySQLdb\constantscopyingMySQLdb\constants\CLIENT.py->build\lib.win-amd64-3.1\MySQLdb\constantsrunningbuild_extbuilding'_mysql'extensioncreatingbuild\temp.win-amd64-3.1creatingbuild\temp.win-amd64-3.1\ReleaseC:\ProgramFiles(x86)\MicrosoftVisualStudio9.0\VC\BIN\amd64\cl.exe/c/nologo/Ox/MD/W3/GS-/DNDEBUG-Dversion_info=(1,2,3,'final',0)-D__version__=1.2.3"-IH:\MySQL\MySQL Server 5.1\include"-IH:\Python31\include-IH:\Python31\PC/Tc_mysql.c/Fobuild\temp.win-amd64-3.1\Release\_mysql.obj/Zl_mysql.c...somewarnings...C:\ProgramFiles(x86)\MicrosoftVisualStudio9.0\VC\BIN\amd64\link.exe/DLL/nologo/INCREMENTAL:NO"/LIBPATH:H:\MySQL\MySQL Server 5.1\lib\opt"/LIBPATH:H:\Python31\libs/LIBPATH:H:\Python31\PCbuild\amd64kernel32.libadvapi32.libwsock32.libmysqlclient.lib/EXPORT:PyInit__mysqlbuild\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_mysql.objwarningLNK4197:export'PyInit__mysql'specifiedmultipletimes;usingfirstspecificationCreatinglibrarybuild\temp.win-amd64-3.1\Release\_mysql.libandobjectbuild\temp.win-amd64-3.1\Release\_mysql.exp_mysql.obj:warningLNK4217:locallydefinedsymbolstrncatimportedinfunction_mysql_row_to_dict_mysql.obj:warningLNK4217:locallydefinedsymbolstrncpyimportedinfunction_mysql_row_to_dict_mysql.obj:warningLNK4217:locallydefinedsymbolsprintfimportedinfunction_mysql_ConnectionObject_reprC:\ProgramFiles\MicrosoftSDKs\Windows\v6.0A\bin\x64\mt.exe-nologo-manifestbuild\temp.win-amd64-3.1\Release\_mysql.pyd.manifest-outputresource:build\lib.win-amd64-3.1\_mysql.pyd;2build\temp.win-amd64-3.1\Release\_mysql.pyd.manifest:generalerrorc1010070:Failedtoloadandparsethemanifest.Systemcouldn't find specified file.error: command 'mt.exe' failed with exit status 31>setup.pyinstallrunninginstallinstall_dirH:\Python31\Lib\site-packages\
runningbdist_eggrunningegg_infowritingMySQL_python.egg-info\PKG-INFOwritingtop-levelnamestoMySQL_python.egg-info\top_level.txtwritingdependency_linkstoMySQL_python.egg-info\dependency_links.txtreadingmanifestfile'MySQL_python.egg-info\SOURCES.txt'readingmanifesttemplate'MANIFEST.in'warning:nofilesfoundmatching'MANIFEST'warning:nofilesfoundmatching'ChangeLog'warning:nofilesfoundmatching'GPL'writingmanifestfile'MySQL_python.egg-info\SOURCES.txt'installinglibrarycodetobuild\bdist.win-amd64\eggrunninginstall_librunningbuild_pycopyingMySQLdb\release.py->build\lib.win-amd64-3.1\MySQLdbrunningbuild_extcreatingbuild\bdist.win-amd64creatingbuild\bdist.win-amd64\eggcreatingbuild\bdist.win-amd64\egg\MySQLdbcopyingbuild\lib.win-amd64-3.1\MySQLdb\connections.py->build\bdist.win-amd64\egg\MySQLdbcreatingbuild\bdist.win-amd64\egg\MySQLdb\constantscopyingbuild\lib.win-amd64-3.1\MySQLdb\constants\CLIENT.py->build\bdist.win-amd64\egg\MySQLdb\constantscopyingbuild\lib.win-amd64-3.1\MySQLdb\constants\CR.py->build\bdist.win-amd64\egg\MySQLdb\constantscopyingbuild\lib.win-amd64-3.1\MySQLdb\constants\ER.py->build\bdist.win-amd64\egg\MySQLdb\constantscopyingbuild\lib.win-amd64-3.1\MySQLdb\constants\FIELD_TYPE.py->build\bdist.win-amd64\egg\MySQLdb\constantscopyingbuild\lib.win-amd64-3.1\MySQLdb\constants\FLAG.py->build\bdist.win-amd64\egg\MySQLdb\constantscopyingbuild\lib.win-amd64-3.1\MySQLdb\constants\REFRESH.py->build\bdist.win-amd64\egg\MySQLdb\constantscopyingbuild\lib.win-amd64-3.1\MySQLdb\constants\__init__.py->build\bdist.win-amd64\egg\MySQLdb\constantscopyingbuild\lib.win-amd64-3.1\MySQLdb\converters.py->build\bdist.win-amd64\egg\MySQLdbcopyingbuild\lib.win-amd64-3.1\MySQLdb\cursors.py->build\bdist.win-amd64\egg\MySQLdbcopyingbuild\lib.win-amd64-3.1\MySQLdb\release.py->build\bdist.win-amd64\egg\MySQLdbcopyingbuild\lib.win-amd64-3.1\MySQLdb\times.py->build\bdist.win-amd64\egg\MySQLdbcopyingbuild\lib.win-amd64-3.1\MySQLdb\__init__.py->build\bdist.win-amd64\egg\MySQLdbcopyingbuild\lib.win-amd64-3.1\_mysql.pyd->build\bdist.win-amd64\eggcopyingbuild\lib.win-amd64-3.1\_mysql_exceptions.py->build\bdist.win-amd64\eggbyte-compilingbuild\bdist.win-amd64\egg\MySQLdb\connections.pytoconnections.pycbyte-compilingbuild\bdist.win-amd64\egg\MySQLdb\constants\CLIENT.pytoCLIENT.pycbyte-compilingbuild\bdist.win-amd64\egg\MySQLdb\constants\CR.pytoCR.pycbyte-compilingbuild\bdist.win-amd64\egg\MySQLdb\constants\ER.pytoER.pycbyte-compilingbuild\bdist.win-amd64\egg\MySQLdb\constants\FIELD_TYPE.pytoFIELD_TYPE.pycbyte-compilingbuild\bdist.win-amd64\egg\MySQLdb\constants\FLAG.pytoFLAG.pycbyte-compilingbuild\bdist.win-amd64\egg\MySQLdb\constants\REFRESH.pytoREFRESH.pycbyte-compilingbuild\bdist.win-amd64\egg\MySQLdb\constants\__init__.pyto__init__.pycbyte-compilingbuild\bdist.win-amd64\egg\MySQLdb\converters.pytoconverters.pycbyte-compilingbuild\bdist.win-amd64\egg\MySQLdb\cursors.pytocursors.pycbyte-compilingbuild\bdist.win-amd64\egg\MySQLdb\release.pytorelease.pycbyte-compilingbuild\bdist.win-amd64\egg\MySQLdb\times.pytotimes.pycbyte-compilingbuild\bdist.win-amd64\egg\MySQLdb\__init__.pyto__init__.pycbyte-compilingbuild\bdist.win-amd64\egg\_mysql_exceptions.pyto_mysql_exceptions.pyccreatingstubloaderfor_mysql.pydbyte-compilingbuild\bdist.win-amd64\egg\_mysql.pyto_mysql.pyccreatingbuild\bdist.win-amd64\egg\EGG-INFOcopyingMySQL_python.egg-info\PKG-INFO->build\bdist.win-amd64\egg\EGG-INFOcopyingMySQL_python.egg-info\SOURCES.txt->build\bdist.win-amd64\egg\EGG-INFOcopyingMySQL_python.egg-info\dependency_links.txt->build\bdist.win-amd64\egg\EGG-INFOcopyingMySQL_python.egg-info\top_level.txt->build\bdist.win-amd64\egg\EGG-INFOwritingbuild\bdist.win-amd64\egg\EGG-INFO\native_libs.txtzip_safeflagnotset;analyzingarchivecontents...creatingdistcreating'dist\MySQL_python-1.2.3-py3.1-win-amd64.egg'andadding'build\bdist.win-amd64\egg'toitremoving'build\bdist.win-amd64\egg'(andeverythingunderit)ProcessingMySQL_python-1.2.3-py3.1-win-amd64.eggcreatingh:\python31\lib\site-packages\MySQL_python-1.2.3-py3.1-win-amd64.eggExtractingMySQL_python-1.2.3-py3.1-win-amd64.eggtoh:\python31\lib\site-packagesAddingMySQL-python1.2.3toeasy-install.pthfileInstalledh:\python31\lib\site-packages\mysql_python-1.2.3-py3.1-win-amd64.eggProcessingdependenciesforMySQL-python==1.2.3FinishedprocessingdependenciesforMySQL-python==1.2.3>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2010-10-04
thanks a million!
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>pythonsetup.pyinstallrunninginstallinstall_dirC:\Python31\Lib\site-packages\
runningbdist_eggrunningegg_infowritingMySQL_python.egg-info\PKG-INFOwritingtop-levelnamestoMySQL_python.egg-info\top_level.txtwritingdependency_linkstoMySQL_python.egg-info\dependency_links.txtreadingmanifestfile'MySQL_python.egg-info\SOURCES.txt'readingmanifesttemplate'MANIFEST.in'warning:nofilesfoundmatching'MANIFEST'warning:nofilesfoundmatching'ChangeLog'warning:nofilesfoundmatching'GPL'writingmanifestfile'MySQL_python.egg-info\SOURCES.txt'installinglibrarycodetobuild\bdist.win-amd64\eggrunninginstall_librunningbuild_pycopyingMySQLdb\release.py->build\lib.win-amd64-3.1\MySQLdbrunningbuild_extbuilding'_mysql'extensionC:\ProgramFiles(x86)\MicrosoftVisualStudio9.0\VC\BIN\amd64\cl.exe/c/nologo/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.cC:\ProgramFiles\MySQL\MySQLServer5.5\include\config-win.h(24):warningC4005:'_WIN32_WINNT':macroredefinitionC:\ProgramFiles\MicrosoftSDKs\Windows\v7.0\include\sdkddkver.h(197):seepreviousdefinitionof'_WIN32_WINNT'C:\ProgramFiles\MySQL\MySQLServer5.5\include\config-win.h(203):warningC4005:'SIZEOF_OFF_T':macroredefinitionc:\python31\include\pyconfig.h(343):seepreviousdefinitionof'SIZEOF_OFF_T'C:\ProgramFiles\MySQL\MySQLServer5.5\include\config-win.h(301):warningC4005:'HAVE_STDDEF_H':macroredefinitionc:\python31\include\pyconfig.h(682):seepreviousdefinitionof'HAVE_STDDEF_H'_mysql.c(242):warningC4244:'=':conversionfrom'Py_ssize_t'to'int',possiblelossofdata_mysql.c(267):warningC4244:'=':conversionfrom'Py_ssize_t'to'int',possiblelossofdata_mysql.c(394):warningC4244:'initializing':conversionfrom'Py_ssize_t'to'int',possiblelossofdata_mysql.c(1004):warningC4244:'=':conversionfrom'Py_ssize_t'to'int',possiblelossofdata_mysql.c(1107):warningC4244:'=':conversionfrom'Py_ssize_t'to'int',possiblelossofdata_mysql.c(1337):warningC4267:'=':conversionfrom'size_t'to'int',possiblelossofdata_mysql.c(1339):warningC4267:'=':conversionfrom'size_t'to'int',possiblelossofdata_mysql.c(1383):warningC4267:'=':conversionfrom'size_t'to'int',possiblelossofdata_mysql.c(1385):warningC4267:'=':conversionfrom'size_t'to'int',possiblelossofdata_mysql.c(2139):warningC4244:'function':conversionfrom'__int64'to'long',possiblelossofdataC:\ProgramFiles(x86)\MicrosoftVisualStudio9.0\VC\BIN\amd64\link.exe/DLL/nologo/INCREMENTAL:NO"/LIBPATH:C:\Program Files\MySQL\MySQL Server 5.5\lib\opt"/LIBPATH:C:\Python31\libs/LIBPATH:C:\Python31\PCbuild\amd64kernel32.libadvapi32.libwsock32.libmysqlclient.lib/EXPORT:PyInit__mysqlbuild\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.manifestLINK:fatalerrorLNK1181:cannotopeninputfile'mysqlclient.lib'error:command'"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\link.exe"'failedwithexitstatus1181
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"</path_to_python_dir>
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></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"</path_to_python_dir>
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 :(