Error using MySQL server and SQLAlchemy
- Dominant language
- Python
- Stars
- 49
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
MySQL Server 5.5
SQLAchemy: 1.1.4
PyMysql: 0.7.9
Source code:
```python
# -*- coding: utf-8 -*-
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from guardrail.core import registry
from guardrail.ext.sqlalchemy import SqlalchemyPermissionSchemaFactory
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = "mysql+pymysql://root:@localhost/test_db?charset=utf8"
db = SQLAlchemy(app)
@registry.agent
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(100), unique=True)
@registry.target
class Post(db.Model):
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(100))
content = db.Column(db.Text)
factory = SqlalchemyPermissionSchemaFactory((db.Model, ))
registry.make_schemas(factory)
db.create_all()
```
Stack trace:
```
column.type, type_expression=column)
File "C:\Python27\lib\site-packages\sqlalchemy\sql\compiler.py", line 290, in process
return type_._compiler_dispatch(self, **kw)
File "C:\Python27\lib\site-packages\sqlalchemy\sql\visitors.py", line 81, in _compiler_dispatch
return meth(self, **kw)
File "C:\Python27\lib\site-packages\sqlalchemy\sql\compiler.py", line 2770, in visit_string
return self.visit_VARCHAR(type_, **kw)
File "C:\Python27\lib\site-packages\sqlalchemy\dialects\mysql\base.py", line 1318, in visit_VARCHAR
self.dialect.name)
sqlalchemy.exc.CompileError: (in table 'user_post_permission', column 'permission'): VARCHAR requires a
length on dialect mysql
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the report with the provided Flask setup and db.create_all() call, then start at SqlalchemyPermissionSchemaFactory and inspect the generated user_post_permission table. Compare the generated permission column with MySQL's VARCHAR requirements. Done means the schema can be created successfully against MySQL 5.5 without this CompileError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, python, sqlalchemy
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100