Skip to content Skip to sidebar Skip to footer

How To Handle Encoding In Python 2.7 And SQLAlchemy 🏴‍☠️

I have written a code in Python 3.5, where I was using Tweepy & SQLAlchemy & the following lines to load Tweets into a database and it worked well: twitter = Twitter(str(tw

Solution 1:

Do not use any encode/decode functions; they only compound the problems.

Do set the connection to be UTF-8.
Do set the column/table to utf8mb4 instead of utf8.
Do use # -*- coding: utf-8 -*- at the beginning of Python code.

More Python tips Note that that has a link to "Python 2.7 issues; improvements in Python 3".


Post a Comment for "How To Handle Encoding In Python 2.7 And SQLAlchemy 🏴‍☠️"