Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
677 views
in Technique[技术] by (71.8m points)

sql - VARCHAR requires a length when rendered on MySQL

I have a buildout instance with pas.plugins.sqlalchemy. It appears in installation list but when installing it results in an error.

Here's the ZCML definition:

<configure xmlns="http://namespaces.zope.org/zope" xmlns:db="http://namespaces.zope.org/db">
<include package="z3c.saconfig" file="meta.zcml" />
<db:engine xmlns="http://namespaces.zope.org/db" name="pas" url="mysql://webadmin:password@rcs-mysql-dev/estep" />
<db:session xmlns="http://namespaces.zope.org/db" name="pas.plugins.sqlalchemy" engine="pas" />
</configure>

Traceback is:

Traceback (innermost last):
  Module ZPublisher.Publish, line 127, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 47, in call_object
  Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 575, in installProducts
  Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 512, in installProduct
   - __traceback_info__: ('pas.plugins.sqlalchemy',)
  Module Products.GenericSetup.tool, line 330, in runAllImportStepsFromProfile
   - __traceback_info__: profile-pas.plugins.sqlalchemy:install
  Module Products.GenericSetup.tool, line 1085, in _runImportStepsFromContext
  Module Products.GenericSetup.tool, line 999, in _doRunImportStep
   - __traceback_info__: pas.plugins.sqlalchemy.install
  Module pas.plugins.sqlalchemy.setuphandlers, line 46, in install
  Module sqlalchemy.schema, line 2148, in create_all
  Module sqlalchemy.engine.base, line 1698, in create
  Module sqlalchemy.engine.base, line 1740, in _run_visitor
  Module sqlalchemy.sql.visitors, line 83, in traverse_single
  Module sqlalchemy.engine.ddl, line 42, in visit_metadata
  Module sqlalchemy.sql.visitors, line 83, in traverse_single
  Module sqlalchemy.engine.ddl, line 58, in visit_table
  Module sqlalchemy.engine.base, line 1191, in execute
  Module sqlalchemy.engine.base, line 1241, in _execute_ddl
  Module sqlalchemy.sql.expression, line 1413, in compile
  Module sqlalchemy.engine.base, line 702, in compile
  Module sqlalchemy.engine.base, line 715, in process
  Module sqlalchemy.sql.visitors, line 54, in _compiler_dispatch
  Module sqlalchemy.sql.compiler, line 1152, in visit_create_table
  Module sqlalchemy.dialects.mysql.base, line 1282, in get_column_specification
  Module sqlalchemy.engine.base, line 761, in process
  Module sqlalchemy.sql.visitors, line 54, in _compiler_dispatch
  Module sqlalchemy.sql.compiler, line 1450, in visit_string
  Module sqlalchemy.dialects.mysql.base, line 1520, in visit_VARCHAR
InvalidRequestError: VARCHAR requires a length when rendered on MySQL
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

you need to specify lengths for all Strings. That means: String(n) instead of simply String. So, in pas.plugins.sqlalchemy.model.User

 login = Column(String, unique=True)

becomes

 login = Column(String(100), unique=True)

etc...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...