title: Flask SQLAlchemy: Attribute Error: 'function' object has no attribute 'translate'
body: <p>I'm trying to insert some values into my database using Flask Restful. I'm using PyMysql with Flask SQlAlchemy for database connection but when I insert, I'm getting the</p>
  
  <pre><code>AttributeError: 'function' object has no attribute 'translate'
  </code></pre>
  
  <p>when I do </p>
  
  <pre><code>db.session.add(self)
  db.session.commit()
  </code></pre>
  
  <p>Error</p>
  
  <pre><code>File "/home/yung/Documents/Projects/Crowlabs/Projects/churchify/venv/lib/python2.7/site-packages/pymysql/converters.py", line 73, in _escape_unicode
  
  def _escape_unicode(value, mapping=None):
      """escapes *value* without adding quote.
  
      Value should be unicode
      """
      return value.translate(_escape_table)
  
      if PY2:
          def escape_string(value, mapping=None):
              """escape_string escapes *value* but not surround it with quotes.
  </code></pre>
  
  <p><strong>My Code</strong></p>
  
  <pre><code>from db import db
  
  class Test(db.Model):
      __tablename__       = "auth_test"
  
      id                  = db.Column(db.Integer, primary_key=True)
      username            = db.Column(db.Text)
      password            = db.Column(db.Text)
      email               = db.Column(db.Text)
      type                = db.Column(db.Text)
  
      def __init__(self, username, password, email, type_):
          self.username       = username
          self.password       = password
          self.email          = email
          self.type           = type_
  
          db.session.add(self)
          db.session.commit()
  </code></pre>
  
  <p>This only comes up when I try to insert into the database but when retrieving it works well</p>