Member-only story
Dynamic MySQL CREATE TABLE statement with pandas and pyodbc
Have you ever had to type out a massive CREATE TABLE
statement by hand? One with dozens of columns? Maybe several dozens of columns? There are likely some GUI tools to help with large CREATE TABLE
commands. Or, other drag-n-drop types of software that I am not familiar with. What if you could write a few lines of Python code and take care of a huge CREATE TABLE
statement with way less effort than typed manually? Interested? Continue reading and see how using pandas, pyodbc, and MySQL…
OS, Software, and DB used:
- OpenSuse Leap 15.1
- MySQL 8.0.20
- Python 3.7.2
- pandas 1.0.4
Self-Promotion:
If you enjoy the content written here, by all means, share this blog and your favorite post(s) with others who may benefit from or like it as well. Since coffee is my favorite drink, you can even buy me one if you would like!
You can download the Stack Overflow Developer Survey Results data set used in this post for your own exploration if you would like.
To start, I’ll import pandas into an ipython
session and specify the path to the target CSV from the Stack Overflow survey results download:
In [1]: import pandas as pd
In [2]…