Forums

Database and unicode Python 2.7.4 and flask-sqlalchemy on Win 7.

Database is functioning localy but here after uploading document with name for example ČarI Đžur I get this error.

Error logs says

2014-05-23 14:19:51,103 :/home/JosipKatalinic/venv/lib/python2.7/site-packages/sqlalchemy/engine/default.py:562: SAWarning: Unicode type received non-unicode bind param value. 2014-05-23 14:19:51,104 : param.append(processorskey)

This has happen after I have changed (migrate) database from name = db.Column(db.String(64)) to name= db.Column(db.UnicodeText(64))

class Skripta(db.Model):
     __tablename__ = 'skripte'
     __searchable__ = ['name']
     id = db.Column(db.Integer, primary_key=True)
     name= db.Column(db.UnicodeText(64))
     location = db.Column(db.String(64))
     rating = db.Column(db.Float(3, 2), default=0)
     author = db.Column(db.Integer, db.ForeignKey('users.id'))

def __unicode__(self):
    return u'<a href=\"%s\"> %s </a>' % (self.location, self.name)

Problem is solved...note to all people...never leave debugging variable alive in production.

The SQLAlchemy UnicodeText column type requires that you pass it a Python unicode string. My guess is that you're somehow passing it a plain Python string and that's why it's complaining.