I am working to add Alembic migration to a legacy project. I am hoping to execute some raw sql, including some insert statements with unicode that I want to be encoded with UTF-8, but am getting a UnicodeDecodeError. To reproduce this error, I created this example:
def upgrade():
op.execute("SELECT '𝔥𝔢𝔩𝔩𝔬'")
When I run this migration, I get:
File "virtual_env/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1263, in execute
return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
File "virtual_env/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 324, in _execute_on_connection
self, multiparams, params, execution_options
File "virtual_env/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1462, in _execute_clauseelement
cache_hit=cache_hit,
File "virtual_env/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1678, in _execute_context
e, util.text_type(statement), parameters, None, None
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 8: ordinal not in range(128)
I confirmed that my Postgres database encoding is set to UTF-8. I also tried to work out whether execution_options parameters exist to set the encoding, but I was not able to discern this. I also tried abandoning op.execute() and tried creating my own engine instance using sa.create_engine(url, encoding='utf-8'), which mysteriously still gave me an encoding error and was wanting to use ascii.
Which Alembic, SQLAlchemy or Psycopg2 subsystem is expecting ascii, and is there a way to change that expectation either in Alembic's configuration or for a specific migration?
I'm happy to dig into the internal APIs and use a hacky solution, but would hope there is a straightforward way to do this that I have just not encountered in a couple hours searching the documentation.
Note: this project uses Python 2.7.16, and despite my efforts I do not have authorization to port it to Python3 yet.
[honestly, this is a WTF for chromium project once again fixing something that wasn't broken -- until a recent update to chromium-based browsers (it shows up in Chrome 91 and Edge 91, but does not manifest itself in Opera 60, nor the latest Firefox)]
To wit: previously, the console would honor/interpret LF (ie \n ) in a character string written to the console log. for example, if you entered
xyz="\nabc\ndef\ng"
the console would display ->
"
abc
def
g"
Now it displays:
"\nabc\ndef\ng"
This totally bollixes all of the embedded functions previously written to be invoked from the console that are intended to write to the console log.
Using \n in output to console log has been promoted on this forum for nearly a decade.
So, is this a new 'feature' or a bug?
String fullBriefDescription = "ຈົວ昨夜, 最高コンサ";
System.out.println("fullBriefDescription Line 1094 "+fullBriefDescription);
System.out.println("fullBriefDescription Length Line 1095 "+fullBriefDescription.length());
I have created a java file and run through Weblogic 12c as a Part of the project, but when I run the project and print output why I am getting "????? ???" instead of the above characters??
Please Help
Is % character encoded to '%25' With URIEncoding="utf-8" setting on server.xml?
I have a file named abc%.wav on the server and try to access it with hyperlink, but the server response 404 not found.
I encoded the file name in the java class file, then it worked fine.
So I am curious whether % character is encoded with the setting above or not.
Thanks.
I'm trying to run report on JasperReports Server. My MySQL db encoding is cp1251.
The result of running report
� "Emika" Ltd, 3
������� 2012
?- must be the Russian symbols. I found solution to set URL in report datasource
jdbc:mysql://localhost:3306/database?useUnicode=true&characterEncoding=cp1251.
But it doesn't works. What I'm doing wrong?
Connection settings
are
Variable_name Value
character_set_client cp1251
character_set_connection cp1251
character_set_database cp1251
character_set_filesystem binary
character_set_result cp1251
character_set_server cp1251
character_set_system utf8
I resolve the problem. I set the parameter init-connect="SET NAMES utf8" in file /etc/mysql/my.cnf