I am a beginner to python and programming in general. But I've been wondering if it is possible to write a python script that would automate tasks on MySQL, like creating new database, user, table etc. For example I would ask the user for name input and after that I would want my script to automatically create a name_db database. I forgot to add that I need the commands not only to execute but to show on my cmd one after another like I wrote them manually. Is it possible to do?
2 Answers
Yes, of course, you can. You have to learn about MySQL connection with python link: https://www.datacamp.com/community/tutorials/mysql-python
And if you going to learn web I suggest Django, all database connections are already there.
Comments
Yes, I posted a link below demonstrating someone issuing sql queries using python code. This is performed using parameters:
https://towardsdatascience.com/a-simple-approach-to-templated-sql-queries-in-python-adc4f0dc511
3 Comments
danblack
the link broken.
Kyle McCurley
Sorry, Should Be Fixed Now
danblack
Yes, answers are previewed so way attention. Be wary of giving link only answers too. Sure this question was bit broad however normally some meaning content should be in an answer and links will just provide more information.