Найти - Пользователи
Полная версия: Непонятная ошбка при создании модели в sqlAlchemy
Начало » Python для новичков » Непонятная ошбка при создании модели в sqlAlchemy
1
$m1t
Вот пытаюсь сделать простенькую модельку
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Table, Column, Integer, String, MetaData
from sqlalchemy import create_engine

Base = declarative_base()

class User(Base):
__tablename__ = "users"
uid = Column(Integer, primary_key=True)
friends = Column(String)
clubs = Column(String)

engine = create_engine('mysql://hr:password@localhost/ht')
Base.metadata.create_all(engine)
Session = sessionmaker(bind=engine)
Получаю
File “/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.5-py2.6.egg/sqlalchemy/engine/base.py”, line 931, in _handle_dbapi_exception
raise exc.DBAPIError.instance(statement, parameters, e, connection_invalidated=is_disconnect)
sqlalchemy.exc.ProgrammingError: (ProgrammingError) (1064, “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ \n\tclubs VARCHAR, \n\tPRIMARY KEY (uid)\n)’ atline 3”) ‘\nCREATE TABLE users (\n\tuid INTEGER NOT NULL AUTO_INCREMENT, \n\tfriends VARCHAR, \n\tclubs VARCHAR, \n\tPRIMARY KEY (uid)\n)\n\n’ ()

Что я делаю не так?
PooH
Попробуйте явно задать для строковых полей максимальную длину.
$m1t
PooH
Спасибо, помогло.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB