Skip to content

Commit 10a7cd0

Browse files
dongweiminggrigi
authored andcommitted
Check whether charset name is available (tortoise#261)
1 parent 39168d0 commit 10a7cd0

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

CHANGELOG.rst

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Changelog
44
=========
5+
Unreleased
6+
------
7+
- Check whether charset name is available
8+
59
0.15.4
610
------
711
- Don't generate a schema if there is no models (#254)

CONTRIBUTORS.rst

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Contributors
2222
* Zoltán Szeredi ``@zoliszeredi``
2323
* Rebecca Klauser ``@svms1``
2424
* Sina Sohangir ``@sinaso``
25+
* Weiming Dong ``@dongweiming``
2526

2627
Special Thanks
2728
==============

tortoise/backends/mysql/client.py

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import aiomysql
66
import pymysql
7+
from pymysql.charset import charset_by_name
78
from pypika import MySQLQuery
89

910
from tortoise.backends.base.client import (
@@ -76,6 +77,8 @@ def __init__(
7677
self._connection = None
7778

7879
async def create_connection(self, with_db: bool) -> None:
80+
if charset_by_name(self.charset) is None: # type: ignore
81+
raise DBConnectionError(f"Unknown charset {self.charset}")
7982
self._template = {
8083
"host": self.host,
8184
"port": self.port,

0 commit comments

Comments
 (0)