0

I'm storing 3 french levels and I'm storing the level name as VARCHAR because I read that postgresql doesn't support NVARCHAR

class Level(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    level_name = db.Column(db.VARCHAR(250))

Here's what I'm trying to store:

level1 = Level(level_name= 'Débutant')
level2 = Level(level_name= 'Intermédiarie')
level3 = Level(level_name= 'Avancé')

And here's the output in Json:

[{"id":1,"level_name":"D\u00e9butant"},
{"id":2,"level_name":"Interm\u00e9diarie"},
{"id":3,"level_name":"Avanc\u00e9"}]

Things I have tried and didn't work:

  1. Changing the type to Unicode
  2. Setting the locale to French with flask-babel
  3. Storing u'Débutant'
Andrea
  • 13
  • 3
  • Can you clarify the problem? The JSON output is correct, just a way of representing non-ASCII characters. And you don't seem to be storing JSON in the database, so it isn't clear how Postgres relates to this. – snakecharmerb Nov 29 '22 at 15:25
  • 1
    [This](https://stackoverflow.com/questions/18337407/saving-utf-8-texts-with-json-dumps-as-utf-8-not-as-a-u-escape-sequence) might be informative. – snakecharmerb Nov 29 '22 at 15:26

0 Answers0