17

I apologize in advance for my lack of knowledge concerning character encoding.

My question is: are there any inherent advantages/disadvantages to using the 'Unicode' type, rather than the 'String' type, when storing data in PostgreSQL using SQLAlchemy (or vice-versa)? If so, would you mind elaborating?

4
  • I assume this is python2? Commented Apr 14, 2015 at 1:50
  • @CraigRinger Yessir. However, your asking that also makes me curious as to how the question, and answer, would differ w/python3. Commented Apr 14, 2015 at 2:22
  • 1
    python3 uses unicode for all string representations, while python2 doesn't. That causes problems for python2 programs that convert between byte strings and unicode strings, which Python3 programs can usually dodge. The python docs have a section that talks about this. This is also a good read on the frustrations of unicode in python2. Despite the annoyance, it's probably best to work with unicode because it seems to be the future-proof direction. Commented Apr 14, 2015 at 3:04
  • 1
    I think the question is about sqlalchemy.Unicode column type vs sqlalchemy.String column type. Not regarding the standard python unicode/string types, of which a lot has been written already. Commented Apr 20, 2019 at 22:06

1 Answer 1

4

In 99.99% of the cases go for Unicode and if possible use Python 3 as it would make your life easier.

Sign up to request clarification or add additional context in comments.

1 Comment

Would it be possible to elaborate on why?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.