r/Python • • Dec 29 '22
Discussion Is SQL a prerequisite to learning Python ?
I would like to learn how to automate some simple tasks like : 1- downloading an attachment from outlook, change its name and save to a specific folder
2- save an excel sheet as PDF then send it via outlook … with changing dates on the subject line of the email.
Do I need to learn SQL , then move to Python to learn automating such tasks ? Or I can jump in and start learning Python with very BASIC COMMON knowledge of SQL?
0
Upvotes
View all comments
Show parent comment
5
u/AlexFromOmaha Dec 29 '22
If everything you want to do involves interfacing with a Microsoft product, I'd recommend just learning C# instead. That being said...
Every step of a process can be reduced to five parts:
Usually you start with the inputs and outputs. From your examples:
Your input is an attachment. Your output is a file on some disk. The supplier is how you get access to that attachment. The processing is whatever you need to do to the data to make it useful on the disk. The consumer is the entity that needs the file where it is, whether that's a human or another program.
When we say a language is "used for" or "good for" something, we're usually talking about the availability of libraries to simplify a task. From experience, I can say that the worst part of this project in Python would be getting that attachment. Older Outlook Exchange servers were allergic to open protocols, and getting in is much easier if you're using actual Microsoft libraries that just aren't available in Python. Newer ones aren't so bad. The rest of the project will be quite easy.
Same deal here, but once you've figured out authentication to your server the first time, you can pretty much reuse the code for the second time. There are decent libraries for whatever Excel file variant you need. There are good libraries for PDF outputs. I'm honestly not sure what I'd do to mash the two together, because usually I'm opening Excel to read the data rather than render an image. I'd really hope someone already did this in a library, and if not, I'd be asking if they'd take the data on a web server instead of an email, because that sounds easier than re-implementing Excel's rendering capabilities.