How to work with pymysql?

Hello, I have a question which is quite difficult to properly Express.I don't understand how me to work effectively with Pymysql in Python.The syntax of the Python I know, mysql is worse, but can work.But at work I have a lot of problems according to the type of the database loading.I had a project that I started learning Python, it was a bot on the VC.There I used Json as a database, that is next to the executable lay a Json with user data, I opened it in code, read/wrote and kept.Of course it's not quite right, maybe you can make queries to the database and get the information I needed, but I ran into some problems.The most strange of them is the preservation of different data types:
def setdigit(self, id, data):
 with self.connect:
 cur = self.connect.cursor()
 cur.execute(f"UPDATE DB.USERS SET {data.keys()[0]}={data[data.leys()[0]]} WHERE id={id}")

 def setstring(self, id, data):
 with self.connect:
 cur = self.connect.cursor()
 cur.execute(f"UPDATE DB.USERS SET {data.keys()[0]}='{data[data.leys()[0]]}' WHERE id={id}")

I'm passing the function ID and {"Key":"value"}
And every time I need to call the function records the number or rows that is not very convenient, still I don't really understand how to load data into database with Python.If you make a function taking arguments separately:
def setdigit(self, id, key, value):
 with self.connect:
 cur = self.connect.cursor()
 cur.execute(f"UPDATE DB.USERS SET {key}={value} WHERE id={id}")

It is natural to call such a function becomes more Gramotkin, though perhaps I should.In General can you explain how exactly to work, and ideally to make every piece of code with the production, which uses pymysql what would I understand how to link the Python and the database.Thank you!
April 19th 20 at 11:59
1 answer
April 19th 20 at 12:01
Solution
You can look at MongoDB. It just JSON-like documents, and in MySQL it is better not to store as data.
Complement the answer comrade. In such cases, SQL databases need to link to other tables. - ellsworth_Wisozk commented on April 19th 20 at 12:04

Find more questions by tags PythonMySQL