Menu

MySQL Python Windows Problem

Help
2008-01-30
2012-09-19
  • Gerald Bayles

    Gerald Bayles - 2008-01-30

    I have Python version 2.5.1 installed on an XP machine.
    I have installed (and re-installed) MySQL-python-1.2.2.win32-py2.5.exe
    I get the same results with both MySQL 5.1.22-rc and 5.0.51a.

    I have followed the steps outlined in "http://docs.turbogears.org/1.0/DatabaseMySQL", which are, briefly:
    Create db...
    mysql> CREATE DATABASE test2;
    Query OK, 1 row affected (0.03 sec)
    mysql> GRANT ALL ON test2.* TO 'george'@'localhost';
    Query OK, 0 rows affected (0.11 sec)

    Set up dev.cfg...
    sqlobject.dburi="mysql://george@localhost/test2"

    When I run "tg-admin sql create", I get the following:
    Using database URI mysql://george@localhost/test2
    Traceback (most recent call last):
    File "C:\Python25\Scripts\tg-admin-script.py", line 8, in <module>
    load_entry_point('TurboGears==1.0.3.2', 'console_scripts', 'tg-admin')()
    File "c:\python25\lib\site-packages\TurboGears-1.0.3.2-py2.5.egg\turbogears\command\base.py", line 389, in main
    command.run()
    File "c:\python25\lib\site-packages\TurboGears-1.0.3.2-py2.5.egg\turbogears\command\base.py", line 144, in run
    command.the_runner.run(sys.argv)
    File "c:\python25\lib\site-packages\SQLObject-0.9.2-py2.5.egg\sqlobject\manager\command.py", line 101, in run
    runner.run()
    File "c:\python25\lib\site-packages\SQLObject-0.9.2-py2.5.egg\sqlobject\manager\command.py", line 307, in run
    self.command()
    File "c:\python25\lib\site-packages\SQLObject-0.9.2-py2.5.egg\sqlobject\manager\command.py", line 666, in command
    tableConstraints = soClass.createTable(applyConstraints=False)
    File "c:\python25\lib\site-packages\SQLObject-0.9.2-py2.5.egg\sqlobject\main.py", line 1378, in createTable
    constraints = conn.createTable(cls)
    File "c:\python25\lib\site-packages\SQLObject-0.9.2-py2.5.egg\sqlobject\dbconnection.py", line 569, in createTable
    self.query(createSql)
    File "c:\python25\lib\site-packages\SQLObject-0.9.2-py2.5.egg\sqlobject\dbconnection.py", line 342, in query
    return self._runWithConnection(self._query, s)
    File "c:\python25\lib\site-packages\SQLObject-0.9.2-py2.5.egg\sqlobject\dbconnection.py", line 255, in _runWithConnection
    val = meth(conn, *args)
    File "c:\python25\lib\site-packages\SQLObject-0.9.2-py2.5.egg\sqlobject\dbconnection.py", line 339, in _query
    self._executeRetry(conn, conn.cursor(), s)
    File "c:\python25\lib\site-packages\SQLObject-0.9.2-py2.5.egg\sqlobject\mysql\mysqlconnection.py", line 125, in _executeRetry
    raise OperationalError(ErrorMessage(e))
    sqlobject.dberrors.OperationalError: BLOB/TEXT column 'username' used in key specification without a key length

     
    • Andy Dustman

      Andy Dustman - 2008-01-30

      This is pretty obviously a Turbogears/SQLObject issue and has nothing really to do with MySQLdb, MySQL, or Windows. If you create an index on a BLOB or TEXT column (same thing only binary vs. text), you need to specify a key length; this is what the error tells you. But since the column is called 'username', it is likely you have selected the wrong column type in your application. I'm no expert on SQLObject but it looks like you should be using StringCol or UnicodeCol. If you're doing this and SQLObject is trying to create a TEXT column in MySQL, that's a bug in SQLObject.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.