question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UTF8MB4 issue with MySQL 8 and PyMySQL

See original GitHub issue

Migrated issue, originally created by Danqing Liu (@danching)

Using MySQL 8 and PyMySQL 0.8.1 with SQLAlchemy 1.2.8.

e = create_engine('mysql+pymysql://account@localhost:3306/db?charset=utf8mb4')
e.connect()

~/lib/python3.6/site-packages/pymysql/cursors.py:170: Warning: (3719, "'utf8' is currently an alias for the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.")
  result = self._query(query)

This doesn’t happen with MySQL 5. I’m already using utf8mb4, so I shouldn’t really see this.

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:23 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
elisongcommented, Nov 27, 2019

my problem was solved according to: https://blog.csdn.net/u010457406/article/details/90440494

version: "3"
services:
  db:
    .......
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - TZ=${TZ}
      - **LANG=C.UTF-8**
1reaction
danqingcommented, Nov 6, 2019

I’m just doing a migration (alembic 1.3.0, pymysql 0.9.3, sqlalchemy 1.3.10):

/Users/danqing/Developer/society-api/env/lib/python3.7/site-packages/pymysql/cursors.py:170: Warning: (3719, "'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.")
  result = self._query(query)
alembic upgrade head
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
...

My connect string is

mysql+pymysql://society@localhost:3306/society?charset=utf8mb4

And my env.py:

from alembic import context
from sqlalchemy import engine_from_config, pool

def run_migrations():
    url = "mysql+pymysql://society@localhost:3306/society?charset=utf8mb4"
    engine = engine_from_config(
        configuration={},
        url=url,
        poolclass=pool.NullPool
    )
    connection = engine.connect()
    context.configure(connection=connection, target_metadata=None)

    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close()


run_migrations()
Read more comments on GitHub >

github_iconTop Results From Across the Web

Python/Mysql UTF8/UTF8MB4 configuration problem?
1 Answer 1 · The VARCHAR and TEXT columns in your WP tables (and zillions of other tables around the globe) were declared...
Read more >
10.9.1 The utf8mb4 Character Set (4-Byte UTF-8 Unicode ...
For a supplementary character, utf8mb4 requires four bytes to store it, whereas utf8mb3 cannot store the character at all. When converting utf8mb3 columns...
Read more >
How to support full Unicode in MySQL databases
Change the character set and collation properties of the databases, tables, and columns to use utf8mb4 instead of utf8 . # For each...
Read more >
MySQL and MariaDB — SQLAlchemy 2.0 Documentation
engine = create_engine("mysql+pymysql://user:pass@some_mariadb/dbname?charset=utf8mb4"). Upon first connect, the SQLAlchemy dialect employs ...
Read more >
3719: 'utf8' is currently an alias for the character set UTF8MB3 ...
https://github.com/PyMySQL/PyMySQL/issues/690 ... Using MySQL 8 for a college project, have My Schema nailed and was going to use Django to display ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found