For simplicity pytest
launches my_server
and mysql_server
(inside docker). my_server
connects to mysql_server
(over host network), then he gets value of SELECT UNIX_TIMESTAMP();
from mysql_server
process it to day of week, then prints number according to day of week:
('mon', 1667768400), # print 1
('tue', 1667854800), # print 2
('wed', 1667941200), # print 3
...
I'm looking for something like this, but I want to change it globally for all opened sessions:
-- one can connect to mysql and
-- change value for current session,
-- but I need to set it globally or
-- somehow change value for another
-- session.
-- for example for monday:
mysql> set session timestamp = 1667768400;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT UNIX_TIMESTAMP();
------------------
| UNIX_TIMESTAMP() |
------------------
| 1667768400 |
------------------
1 row in set (0.00 sec)
mysql> set global timestamp = 1667768400;
ERROR 1228 (HY000): Variable 'timestamp' is a SESSION variable and can't be used with SET GLOBAL
Notes:
- I can't change code inside
my_server
, it's very expensive; - I can't change host machine timestamp, because such an action would require to run tests with sudo, which is strange requirement for a test.
Kind regards,
Oleg
CodePudding user response:
I dare to suggest the idea of MySQL-proxy for modifying queries transmitted to the SQL server. You can look at this as a starting point: https://github.com/mysql/mysql-proxy