Comments (6)
Not familiar with MySQL, only used postgres and sqlite which explains why I haven't run into this issue myself.
Did a bit of research and doesn't look like Django provides the ability to set charsets on the tables and will assume UTF-8. See here and here for stackoverflow threads where people are facing a similar issue with MySQL.
Looks like you can use the following for database default charsets:
ALTER DATABASE database_name CHARACTER SET utf8 COLLATE utf8_general_ci;
which should ensure that any tables created by Django take UTF from then on. And then if you want to retroactively fit the existing silk tables:
ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8;
Hope this helps.
from django-silk.
Interesting, looks like some kind of encoding issue, see https://docs.djangoproject.com/en/dev/ref/unicode/, in particular the MySQL comments.
I can see from the page content that the charset is utf-8, is your MySQL database configured to support UTF char encodings?
Let me know, if this is the issue i'll add some defensive code to Silk to try and spot this kind of thing. Obviously this error is pretty unhelpful...
Cheers.
from django-silk.
In the meantime if you set the following in settings.py:
SILKY_MAX_REQUEST_BODY_SIZE = 0
SILKY_MAX_RESPONSE_BODY_SIZE = 0
then silk will stop saving the bodies down. As long as you have no UTF characters in the query params/headers etc the error should go away and you can use Silk minus body inspection
from django-silk.
That is a good question, you tell me! :) The encodings are set on a per-table basis.
MySQL says of the silk tables:
mysql> show create table silk_response\G
*************************** 1. row ***************************
Table: silk_response
Create Table: CREATE TABLE `silk_response` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`request_id` int(11) NOT NULL,
`status_code` int(11) NOT NULL,
`raw_body` longtext NOT NULL,
`body` longtext NOT NULL,
`encoded_headers` longtext NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `request_id` (`request_id`),
CONSTRAINT `request_id_refs_id_da922f86` FOREIGN KEY (`request_id`) REFERENCES `silk_request` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
mysql> show create table silk_request\G
*************************** 1. row ***************************
Table: silk_request
Create Table: CREATE TABLE `silk_request` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`path` varchar(300) NOT NULL,
`query_params` longtext NOT NULL,
`raw_body` longtext NOT NULL,
`body` longtext NOT NULL,
`method` varchar(10) NOT NULL,
`start_time` datetime NOT NULL,
`view_name` varchar(300) NOT NULL,
`end_time` datetime DEFAULT NULL,
`time_taken` double DEFAULT NULL,
`encoded_headers` longtext NOT NULL,
`meta_time` double DEFAULT NULL,
`meta_num_queries` int(11) DEFAULT NULL,
`meta_time_spent_queries` double DEFAULT NULL,
`num_sql_queries` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `silk_request_73e78684` (`path`),
KEY `silk_request_b2ae6dce` (`view_name`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
So they're latin-1 by default, it seems.
Thanks for the workaround.
from django-silk.
Closing this as Django does not present any method in which to force table encodings so nothing can be done from the Silk side of things.
from django-silk.
Not familiar with MySQL, only used postgres and sqlite which explains why I haven't run into this issue myself.
Did a bit of research and doesn't look like Django provides the ability to set charsets on the tables and will assume UTF-8. See here and here for stackoverflow threads where people are facing a similar issue with MySQL.
Looks like you can use the following for database default charsets:
ALTER DATABASE database_name CHARACTER SET utf8 COLLATE utf8_general_ci;which should ensure that any tables created by Django take UTF from then on. And then if you want to retroactively fit the existing silk tables:
ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8;Hope this helps.
Thanks, this works for me 😄
from django-silk.
Related Issues (20)
- I can't include database inserts in profiling
- Silk re-uses DB connection for failed atomic transactions.
- SILKY_HIDE_COOKIES does not hide cookie header in different case
- Silk not showing overall and 0 for queries HOT 2
- Request for changing connection database from PRINCIPAL CONNECTION to SQLite or other (SILK)
- Use Graphql, how to count the time for each specific request
- [Python 3.12] ValueError: Another profiling tool is already active
- Curl and Django Test Client URL parameters are being url encoded
- Add api to access request_id of current request
- Is it possible to track Cache(redis) queries?
- Defaults - filter silk itself from requests
- Defaults - use list view not card view HOT 1
- 1054, "Unknown column 'prof_file' in 'field list'"
- Summary stats and profile stats disconnect...
- `Request.objects.all().delete()` is dangerous HOT 2
- Localized profiling
- django.utils.encoding.DjangoUnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 2: invalid start byte.
- Incorrect (Blank) Table Identification in SQL Queries for Update Operation
- Should we consider requirement `autopep8` only as development only? HOT 2
- hope the silk should not be access when set DEBUG=False
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-silk.