Skip to content

Commit

Permalink
fix: mysql set session timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
long2ice committed Jul 26, 2024
1 parent f49151b commit 82abb00
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tortoise/backends/mysql/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async def create_connection(self, with_db: bool) -> None:
self.capabilities.__dict__["supports_transactions"] = False
hours = timezone.now().utcoffset().seconds / 3600 # type: ignore
tz = "{:+d}:{:02d}".format(int(hours), int((hours % 1) * 60))
await cursor.execute(f"SET SESSION time_zone='{tz}';")
await cursor.execute(f"SET time_zone='{tz}';")
self.log.debug("Created connection %s pool with params: %s", self._pool, self._template)
except errors.OperationalError:
raise DBConnectionError(f"Can't connect to MySQL server: {self._template}")
Expand Down

0 comments on commit 82abb00

Please sign in to comment.