Pyramid application with MySQL (SqlAlchemy) in Windows

743 views
Skip to first unread message

Learner

unread,
May 27, 2012, 3:55:52 PM5/27/12
to pylons-discuss
Hello All,

I just started learning Pyramid & Python together. Pyramid
documentation is amazing, step by step instructions are really
helpful for a basic learner like me.

I created a simple Pyramid (SqlAlchemy) application using
http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/tutorials/wiki2/index.html
documentation. Now I want to switch from SqlLite to MySql. So I made
below changes to my application
development.ini
----------------------
sqlalchemy.url = mysql://root:welcome@localhost/deals

Added python-mysql to setup.py
-----------------------------------------------
requires = [
'pyramid',
'mysql-python',
'SQLAlchemy',
'transaction',
'pyramid_tm',
'pyramid_debugtoolbar',
'zope.sqlalchemy',
'waitress',
]

Now when I try to install the application using "python setup.py
develop", I get "error: The system cannot find the file specified"
error.
I tried copying mysql dll file to python bin directory thinking mysql
is not accessible from python & searched on the web but no luck.

Any help is much appreciated. Thanks for your time.

Complete execution details
(pyramid) D:\learner\python\pyramid\projects\tutorial>python setup.py
develop
running develop
running egg_info
writing requirements to tutorial.egg-info\requires.txt
writing tutorial.egg-info\PKG-INFO
writing top-level names to tutorial.egg-info\top_level.txt
writing dependency_links to tutorial.egg-info\dependency_links.txt
writing entry points to tutorial.egg-info\entry_points.txt
reading manifest file 'tutorial.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.rst'
warning: no files found matching '*.jpg' under directory 'tutorial'
warning: no files found matching '*.txt' under directory 'tutorial'
warning: no files found matching '*.mak' under directory 'tutorial'
warning: no files found matching '*.mako' under directory 'tutorial'
warning: no files found matching '*.js' under directory 'tutorial'
warning: no files found matching '*.html' under directory 'tutorial'
warning: no files found matching '*.xml' under directory 'tutorial'
writing manifest file 'tutorial.egg-info\SOURCES.txt'
running build_ext
Creating d:\learner\python\pyramid\lib\site-packages\tutorial.egg-link
(link to .)
tutorial 0.0 is already the active version in easy-install.pth
Installing initialize_tutorial_db-script.py script to D:\learner\python
\pyramid\Scripts
Installing initialize_tutorial_db.exe script to D:\learner\python
\pyramid\Scripts
Installing initialize_tutorial_db.exe.manifest script to D:\learner
\python\pyramid\Scripts

Installed d:\learner\python\pyramid\projects\tutorial
Processing dependencies for tutorial==0.0
Searching for mysql-python
Reading http://pypi.python.org/simple/mysql-python/
Reading http://sourceforge.net/projects/mysql-python/
Reading http://sourceforge.net/projects/mysql-python
Best match: MySQL-python 1.2.3
Downloading http://download.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3.tar.gz
Processing MySQL-python-1.2.3.tar.gz
Running MySQL-python-1.2.3\setup.py -q bdist_egg --dist-dir c:\users
\learner\appdata\local\temp\easy_install-klhsdv\MySQL-python-1.2.3\egg-
dist-tmp-whnjbg
error: The system cannot find the file specified


cheers


Completed

Chris Lambacher

unread,
May 27, 2012, 5:24:55 PM5/27/12
to pylons-...@googlegroups.com
It looks like it is going to try to build MySQL-python from c source. The error may be because of a missing compiler or maybe the MySQL header file or .lib file is missing.

See http://stackoverflow.com/questions/645943/mysql-for-python-in-windows for instructions on getting MySQL-python for windows installed on your system. Note, if you are working against a virtualenv (you are if you are following the tutorial), you can easy_install the downloaded exe installer to get it in your virtualenv. 

-Chris
--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To post to this group, send email to pylons-...@googlegroups.com.
To unsubscribe from this group, send email to pylons-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.



--
Christopher Lambacher
ch...@kateandchris.net

Atsushi Odagiri

unread,
May 28, 2012, 2:29:36 AM5/28/12
to pylons-...@googlegroups.com
Hi

I'm using PyMySQL for MySQL Driver.
It's pure python, so you don't need compile that.

Cheers

2012/5/28 Chris Lambacher <ch...@kateandchris.net>



--
/*
Atsushi Odagiri
http://blog.aodag.jp
mailto:aod...@gmail.com
*/

Learner

unread,
May 28, 2012, 4:33:43 PM5/28/12
to pylons-discuss
Hi Atsushi,

Thanks. I installed PyMySQL now and modified setup.py to include
pymysql library. But Pyramid is still looking for "MysqlDB" module.
May be I am missing something? Please excuse my novice skills

Log trace

(pyramid) D:\learner\python\pyramid\projects\tutorial>pserve
development.ini --reload
Starting subprocess with file monitor
Traceback (most recent call last):
File "D:\learner\python\pyramid\Scripts\pserve-script.py", line 8,
in <module>
load_entry_point('pyramid==1.3.2', 'console_scripts', 'pserve')()
File "D:\learner\python\pyramid\lib\site-packages\pyramid-1.3.2-
py2.7.egg\pyramid\scripts\pserve.py", line 47, in main
return command.run()
File "D:\learner\python\pyramid\lib\site-packages\pyramid-1.3.2-
py2.7.egg\pyramid\scripts\pserve.py", line 290, in run
relative_to=base, global_conf=vars)
File "D:\learner\python\pyramid\lib\site-packages\pyramid-1.3.2-
py2.7.egg\pyramid\scripts\pserve.py", line 318, in loadapp
return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
File "D:\learner\python\pyramid\lib\site-packages\pastedeploy-1.5.0-
py2.7.egg\paste\deploy\loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "D:\learner\python\pyramid\lib\site-packages\pastedeploy-1.5.0-
py2.7.egg\paste\deploy\loadwsgi.py", line 272, in loadobj
return context.create()
File "D:\learner\python\pyramid\lib\site-packages\pastedeploy-1.5.0-
py2.7.egg\paste\deploy\loadwsgi.py", line 710, in create
return self.object_type.invoke(self)
File "D:\learner\python\pyramid\lib\site-packages\pastedeploy-1.5.0-
py2.7.egg\paste\deploy\loadwsgi.py", line 146, in invoke
return fix_call(context.object, context.global_conf,
**context.local_conf)
File "D:\learner\python\pyramid\lib\site-packages\pastedeploy-1.5.0-
py2.7.egg\paste\deploy\util.py", line 56, in fix_call
val = callable(*args, **kw)
File "d:\learner\python\pyramid\projects\tutorial\tutorial
\__init__.py", line 9, in main
engine = engine_from_config(settings, 'sqlalchemy.')
File "build\bdist.win32\egg\sqlalchemy\engine\__init__.py", line
354, in engine_from_config
File "build\bdist.win32\egg\sqlalchemy\engine\__init__.py", line
336, in create_engine
File "build\bdist.win32\egg\sqlalchemy\engine\strategies.py", line
64, in create
File "build\bdist.win32\egg\sqlalchemy\connectors\mysqldb.py", line
52, in dbapi
ImportError: No module named MySQLdb


Any response is much appreciated

cheers
-bkumar

On May 28, 7:29 am, Atsushi Odagiri <aod...@gmail.com> wrote:
> Hi
>
> I'm using PyMySQL for MySQL Driver.
> It's pure python, so you don't need compile that.
>
> Cheers
>
> 2012/5/28 Chris Lambacher <ch...@kateandchris.net>
>
>
>
>
>
>
>
>
>
> > It looks like it is going to try to build MySQL-python from c source. The
> > error may be because of a missing compiler or maybe the MySQL header file
> > or .lib file is missing.
>
> > Seehttp://stackoverflow.com/questions/645943/mysql-for-python-in-windowsforinstructions on getting MySQL-python for windows installed on your
> > system. Note, if you are working against a virtualenv (you are if you are
> > following the tutorial), you can easy_install the downloaded exe installer
> > to get it in your virtualenv.
>
> > -Chris
>
> > On Sunday, May 27, 2012, Learner wrote:
>
> >> Hello All,
>
> >> I just started learning Pyramid & Python together. Pyramid
> >> documentation is amazing, step by step instructions  are really
> >> helpful for a basic learner like me.
>
> >> I created a simple Pyramid (SqlAlchemy) application using
>
> >>http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/tutorial...
> >> Readinghttp://sourceforge.net/projects/mysql-python
> >> Best match: MySQL-python 1.2.3
> >> Downloading
> >>http://download.sourceforge.net/sourceforge/mysql-python/MySQL-python...

Atsushi Odagiri

unread,
May 28, 2012, 8:43:32 PM5/28/12
to pylons-...@googlegroups.com
Hi

Maybe your connection string is "mysql://....".
Using pymysql with sqlalchemy, connection string must be "mysql+pymysql://...."

Cheers

2012/5/29 Learner <hello....@gmail.com>



--
/*

Stefano Fontanelli

unread,
May 29, 2012, 3:27:10 AM5/29/12
to pylons-...@googlegroups.com

Hi Learner,
you must change the driver in your scripts.
Check:
http://docs.sqlalchemy.org/en/latest/core/engines.html?highlight=engine#supported-databases

Stefano.



Il 28/05/12 22.33, Learner ha scritto:
>>>> I just started learning Pyramid& Python together. Pyramid
>>>> documentation is amazing, step by step instructions are really
>>>> helpful for a basic learner like me.
>>>> I created a simple Pyramid (SqlAlchemy) application using
>>>> http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/tutorial...
>>>> documentation. Now I want to switch from SqlLite to MySql. So I made
>>>> below changes to my application
>>>> development.ini
>>>> ----------------------
>>>> sqlalchemy.url = mysql://root:welcome@localhost/deals
>>>> Added python-mysql to setup.py
>>>> -----------------------------------------------
>>>> requires = [
>>>> 'pyramid',
>>>> 'mysql-python',
>>>> 'SQLAlchemy',
>>>> 'transaction',
>>>> 'pyramid_tm',
>>>> 'pyramid_debugtoolbar',
>>>> 'zope.sqlalchemy',
>>>> 'waitress',
>>>> ]
>>>> Now when I try to install the application using "python setup.py
>>>> develop", I get "error: The system cannot find the file specified"
>>>> error.
>>>> I tried copying mysql dll file to python bin directory thinking mysql
>>>> is not accessible from python& searched on the web but no luck.
--
Stefano Fontanelli
Asidev S.r.l.
Viale Rinaldo Piaggio, 32 - 56025 Pontedera (Pisa)
Tel. (+39) 333 36 53 294
Fax. (+39) 0587 97 01 20
E-mail: s.font...@asidev.com
Skype: stefanofontanelli
Twitter: @stefontanelli
LinkedIn: http://it.linkedin.com/in/stefanofontanelli

Learner

unread,
May 29, 2012, 3:26:15 PM5/29/12
to pylons-discuss
After changing the URL, everything is ok.

Loving python & pyramid. Thanks for your help Atsushi & Stefano

cheers
-Bkumar


On May 29, 8:27 am, Stefano Fontanelli <s.fontane...@asidev.com>
wrote:
> Hi Learner,
> you must change the driver in your scripts.
> Check:http://docs.sqlalchemy.org/en/latest/core/engines.html?highlight=engi...
> >>> Seehttp://stackoverflow.com/questions/645943/mysql-for-python-in-windows...on getting MySQL-python for windows installed on your
> E-mail: s.fontane...@asidev.com
Reply all
Reply to author
Forward
0 new messages