mysql-connector-python

Set and verify SSL/TLS version used in Python MySQL connection

雨燕双飞 提交于 2021-02-20 18:49:06
问题 How can I tell the Python MySQL connector which SSL/TLS protocol to use? Either specific (e.g. TLS1.2) or minimum. How can I check which protocol is used on an established connection? I've got an app that uses mysql-connector-python (8.0.18). I connect something like this: cnx = mysql.connector.connect(user='x', password='y', host='localhost', database='xyz') Usually this gives me no trouble, but recently on a web hosting providers server it stopped working. The error I'm now getting is along

Set and verify SSL/TLS version used in Python MySQL connection

余生颓废 提交于 2021-02-20 18:48:03
问题 How can I tell the Python MySQL connector which SSL/TLS protocol to use? Either specific (e.g. TLS1.2) or minimum. How can I check which protocol is used on an established connection? I've got an app that uses mysql-connector-python (8.0.18). I connect something like this: cnx = mysql.connector.connect(user='x', password='y', host='localhost', database='xyz') Usually this gives me no trouble, but recently on a web hosting providers server it stopped working. The error I'm now getting is along

How do I get sqlalchemy.create_engine with mysqlconnector to connect using mysql_native_password?

萝らか妹 提交于 2021-01-29 17:28:41
问题 I'm working with pandas and sqlalchemy, and would like to load a DataFrame into a MySQL database. I'm currently using this code snippet: db_connection = sqlalchemy.create_engine('mysql+mysqlconnector://user:pwd@hostname/db_name') some_data_ref.to_sql(con=db_connection, name='db_table_name', if_exists='replace') sqlalchemy , pandas have been imported prior to this. My MySQL backend is 8.x, which I know uses caching_sha2_password . If I were to connect to the database using mysql.connector

Django admin 404 error when creating or editing a model instance

本小妞迷上赌 提交于 2021-01-03 05:37:10
问题 I'm currently debugging a weird problem with a Django site where one specific model is triggering a 404 error when creating a new instance or editing an existing one in the admin interface. Specifically, the error occurs when the form is submitted. I can GET the changeform just fine. This is only occuring on the live site and only when saving this model. All other models behave as expected, and when I run it locally, everything works as expected. When created programatically, everything is

Django admin 404 error when creating or editing a model instance

家住魔仙堡 提交于 2021-01-03 05:36:14
问题 I'm currently debugging a weird problem with a Django site where one specific model is triggering a 404 error when creating a new instance or editing an existing one in the admin interface. Specifically, the error occurs when the form is submitted. I can GET the changeform just fine. This is only occuring on the live site and only when saving this model. All other models behave as expected, and when I run it locally, everything works as expected. When created programatically, everything is

Python3.8, MySQL5.7: passing active wildcards to LIKE query

别等时光非礼了梦想. 提交于 2020-07-22 05:43:09
问题 I am using python3.8 and mysql.connector. Can I parameterize a query that contains a LIKE clause and pass in active % wildcard(s)? To tame the incoming pattern I have tried: pattern = re.sub(r'%+', '%', target) ~and~ pattern = re.sub(r'%+', '%%', target) ~and~ pattern = re.sub(r'%+', '\\%', target) for the queries I have tried: cursor.execute(f""" DELETE FROM thnigs WHERE user = %(user)s AND widget LIKE %(pattern)s """, dict(user=username, pattern=pattern)) cursor.execute(f""" DELETE FROM

MySQL Connector/Python: How to use the start_transaction() method?

最后都变了- 提交于 2020-05-17 06:20:26
问题 I am trying to access some records using MySQL Connector/Python but I am unable to understand how start_transaction() is used. I would be great if someone could shed some light on uses cases where it is required. Update: After reading the docs carefully it looks like, the start_transaction() method is only required when autocommit=True . Is that true? I am still confused over this and documentation doesn't provide any examples. 回答1: Yes, you normally use the connection.start_transaction()

Is there a way to use 'pool_reset_connection' from mysql-connector-python with MariaDB 10.4.7?

空扰寡人 提交于 2020-05-16 03:10:11
问题 I want to change my python program from a normal connection to a Connection Pool so that the database connection doesn't get lost when no queries are sent for some hours, as well as the database not being overwhelmed with a bunch of queries at once at peak usage. I'm using Python 3.7.4, mysql-connector-python 8.0.17, and MariaDB 10.4.7. It works fine when I use a normal connection, but MariaDB apparently doesn't support the pool_reset_session setting of mysql.connector.pooling