On Tue, Feb 19, 2013 at 6:53 AM, Gert V <[email protected]> wrote: > I'm new to pyramids and python, so forgive me my stupid questions. > The required things for my project are: working with python 3, using > assynchronous calls to the server. > > Currently I'm trying to set up a connection to my MySQL database located at > 127.0.0.1:3306. > "C:\env\lib\site-packages\sqlalchemy-0.8.0b2-py3.3.egg\sqlalchemy\connect > ors\mysqldb.py", line 57, in dbapi > return __import__('MySQLdb') > ImportError: No module named 'MySQLdb' > > First we tried using our full connection string which worked in Pythonwin to > connect and send querry's to our mysql database. > engine = > create_engine('mysql+mysqlconnector://admin:[email protected]/dbeerste', > echo=True) which we changed to ==> > sqlalchemy.url = mysql+mysqlconnector://admin:[email protected]/dbeerste > but that also wouldn't work.
It sounds like either your Python-MySQL interface library is not installed in the virtualenv, or there's a discrepency between your connection string, SQLAlchemy, and the library -- i.e., one part is trying to use one library but a different library is installed. I've always used MySQL-python, which is the most common library. However, it says it doesn't support Python 3 yet. MySQL-python does use the naming convention of "MySQLdb", although I don't remember which letters are uppercase. It changed at one point but that was pre-SQLAlchemy. Traditionally when you use a plain "mysql:" prefix, it chooses MySQL-python, so that must be what it's doing and it's failing to find it. I've never used MySQ-Connector or any of the others; they must have appeared after I switched to PostgreSQL a couple years ago. But if it's working in Pywin but not in your virtualenv, that suggests that MySQL-Connector is not installed in the virtualenv. So you can either install it or try building a virtualenv that enables site-packages. You can also look at the regular MySQL-Connector documentaton and see what to import, and try importing it in the Python shell or at the beginning of your myapp/__init__.py. That would prove definitively whether Python can find it. Also, you don't need the "@127.0.0.1" suffix in a standard installation of MySQL and Python-MySQL, at least on Unix where domain sockets are available. I don't know whether Windows or MySQL-Connector requires it, but it does mean you're going through a TCP socket rather than a domain socket. (Unless the SQLAlchemy dialect or MySQL-Connector converts it behind the scenes.) I'm not sure if domain sockets are available on Windows, but it may add a bit of efficiency, and it would allow the server to not listen on TCP at all. If it does listen on TCP, the main issue is to not let it listen on a non-localhost address unless you specifically need remote clients to connect to it, because it's a potential security hole. -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/pylons-discuss?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
