Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Using MySQL but noticed that your Python scripts no longer able to retrieve data as usual?

If the following symptoms apply to you:

  • You recently migrated from Azure MariaDB to Azure MySQL.
  • MySQL Workbench is able to return data successfully.
  • You have not made any changes to your Python scripts, but they are no longer able to retrieve data as they did before the migration.

What you should do?
  • Please check if you are using mysql-connector as your library. If yes, please uninstall it by using this command:
    • pip uninstall mysql-connector -y
  • After that, please run this command to install the correct MySQL library for Python:
    • pip install mysql-connector-python

Some useful reference articles related to this issue:

Hit "Authentication plugin 'caching_sha2_password' is not supported" when you are using mysql-connector with Python?

 Hit "Authentication plugin 'caching_sha2_password' is not supported" when you are using mysql-connector with Python?


Well, the answer is:

a). Uninstall mysql-connector, and

pip uninstall mysql-connector

b). Proceed to install mysql-connector-python

pip install mysql-connector-python


Enjoy scripting!

10 steps to setup your Python Luno trading bots on Microsoft Azure

10 steps to setup your Python Luno trading bots on Microsoft Azure.

Step 1: Create a Virtual Machine for Ubuntu with size = B1s. You may choose the cheapest region, which is East US 2 - refer https://azureprice.net/You do not need any graphical user interface for this Ubuntu.


Step 2: Now, configure the SSH to only allows the public IP address from your computer.

Step 3: Log into that Virtual Machine to remove Python 2.7 and upgrade it to version 3.10 - refer https://www.itsupportwale.com/blog/how-to-upgrade-to-python-3-10-on-ubuntu-18-04-and-20-04-lts/. Remember to install pip too.

Step 4: Now, install MySQL on your Virtual Machine using sudo command - refer https://linuxize.com/post/how-to-install-mysql-on-ubuntu-18-04/.

Step 5: After that, install MySQL Client, MySQL Connector and Luno Python SDK on Python 3.10 inside your Virtual Machine. You might need setuptools as pre-requisites.

Step 6. Deploy the Python scripts for your bots.

Step 7. Check the configurations file.

Step 8. Build the database for your bots, which will be used to store trading information.

Step 9. Use nohup command to execute your Python bots at background.

Step 10. Use ps aux command to check whether your Step 9 has been done correctly or not.

Thanks.

"Character set 'utf8' unsupported" when you run Python script with MySQL database?

When you run Python script with MySQL database, system gives you this error message:

Character set 'utf8' unsupported


What Do You Need To Do?

pip uninstall mysql-connector-python

Specified key was too long; max key length is 767 bytes

Getting this error "Specified key was too long; max key length is 767 bytes" from your MySQL?

Here is the solution:


  • Simple, just upgrade your MySQL to at least version 5.7.30.

You may download the GA releases from here: https://dev.mysql.com/downloads/mysql/

Want to know your MySQL database size?

Well, you can try the script below:

Select
table_schema As "Database Name",
Round(Sum(data_length + index_length) / 1024 / 1024, 2) As "Database Size in MB"
From information_schema.Tables
Where table_schema = 'xxxxx'
Group By table_schema
Order By table_schema;