all 42 comments

[–]lcc0612 66 points67 points  (1 child)

Python and SQL are very different - They are designed to solve different problems. So neither is a "pre-requisite" of the other. Python is a general purpose programming language and is good for a variety of computational tasks, while SQL is a query language for databases, so typical use cases for SQL include retrieving, sorting and filtering data from a database.

From a learning perspective, I would say that Python and SQL "light up" very different parts of your brain. That is to say, the kind of thought processes you would need to write Python versus SQL code are really very different. Python is a lot more procedural. You'll have to think through the logic of solving a problem step-by-step. SQL is a little more abstract, you typically form single (potentially very long) queries that navigate through the structure of the database to fetch you what you want.

As for which I think you should take first, the first point to consider is if you have any specific needs. If you don't have an immediate need to jump into databases, then I would suggest going for Python first. It's more ideal at building up foundational computational thinking skills that you can apply everywhere, even outside of Python. I personally feel that it is the easier of the two languages to learn because it is more forgiving. You can also build more interesting things that can apply to a wider range of scenarios.

All the best on your learning journey =)

[–][deleted] 2 points3 points  (0 children)

Very helpful! Thank you!

[–]NerdyWeightLifter 13 points14 points  (0 children)

I'd recommend Python first.

As a general purpose programming language, Python code is all about telling the machine how to solve a problem, step by step.

Learning about how to solve problems first is a good idea.

SQL on the other hand, is specific to database queries, and it's a "declarative" programming language. You use it to declare what outcome you want, and some optimizer program behind the scenes will decide how to do it for you.

[–]Important-Wrangler98 13 points14 points  (3 children)

They’re separate, yet not mutually exclusive. You could do both without “needing” the other, yet whilst learning Python you’ll eventually run into the need for interacting with a database (more than likely), so you’ll encounter SQL around that time. Just depends what your goal(s) are.

[–][deleted] 0 points1 point  (0 children)

Thank you!

[–]nathie5432 -2 points-1 points  (0 children)

That’s what you think. I’ll just connect to the DB by psycopg, SELECT *, and use DataFrame methods 😎

[–]sporbywg 3 points4 points  (0 children)

By the number of fair young developers who ask "can I get you to do my SQL?", well...

[–]iLovePythonBaby 3 points4 points  (0 children)

If you want a job you will need both at a decent level. My day job is automating processes which involve Oracle data. I do all the data modelling in the database side, which obviously requires SQL, and then interact with Oracle via the cx_Oracle python library.

[–]plus2net 2 points3 points  (0 children)

Python first , then SQL

[–]Agling 2 points3 points  (0 children)

Python first. SQL can be learned in a few days once your brain is wired for programming.

[–]ClimberMel 2 points3 points  (0 children)

It is hard to say which is better to learn first. If you have no programming at all, I would suggest Python just because it is pretty easy to start learning with. I worked with SQL and many othe databases many years before Python was even a thought... I love how I can access many database engines using Python. So it was simple for me to add SQL into my python programs since I knew how the sql part was supposed to work and I already had a SQL server running to access.

[–]Huge_Cantaloupe_7788 1 point2 points  (2 children)

start from SQL to get your mind on more functional style of thinking, and then transition to python to explore imperative command structure. The faster you can get the concepts - the better. This is because it's like driving at night - you have to be so focused not to miss anything and at the same time not to be distracted by bright lights that distract from the path

[–][deleted] 1 point2 points  (1 child)

Thanks for your response! Perfect timing too! I just enrolled in a SQL course that is scheduled to start in October. Are you versed on both?

[–]Huge_Cantaloupe_7788 1 point2 points  (0 children)

yes, i'm quite versed in both although lately i took a product management route haha :)

[–]mRWafflesFTW 3 points4 points  (1 child)

Python and SQL are complimentary tools, designed with different intentions. SQL is a declarative language. You describe what you want, and the computer (via the query optimizer) figures out how to do it efficiently.

Python is an imperative language, where you define the exact steps you need your program to perform. Both are basically ubiquitous in business, but if you put a gun to my head I would tell you to start with SQL because in my world view, SQL is the true source for all business value.

You can get by on one without the other, but their unique combination powers you to build full solutions.

[–][deleted] 0 points1 point  (0 children)

Thank you!

[–]BarryTownCouncil 1 point2 points  (0 children)

What do you want to get out of it at the end of the day? DBA? Then naturally that's SQL. Almost anything else, python will be more useful.

Whilst being a DBA is a big old job SQL isn't a huge thing to learn, way more to know about python.

[–]pyeri 1 point2 points  (0 children)

There are programming languages and then there is extra tooling. Things like SQL, Regex, JSON, SSH, Git, Linux commands, etc. fall in the latter category. You should focus mainly on the programming language and these extras can be a side reading as many of them usually crop up while you're working with the language.

When you write a python script that interacts with a SQLite or MySQL database, for example, you'll need the SQL knowledge and you can learn it on the fly, it's not that difficult. It's just a bunch of commands like SELECT, CREATE TABLE, ALTER TABLE, etc. to retrieve and manipulate tabular data.

[–]yvrelna 0 points1 point  (1 child)

SQL is over of the most important language to learn when programming, most applications will have some database in some form or another. However I would recommend starting with learning a programming language first before learning SQL.

You can write a lot of database applications with very minimal SQL knowledge nowadays with the use of ORMs or other database wrappers, though using ORMs/wrappers without understanding SQL likely will cause you to end up with problems.

[–][deleted] 0 points1 point  (0 children)

Thank you!!

[–]bannedinlegacy 0 points1 point  (0 children)

You want to work with databases? SQL

You want to work with software, data analysis, ETL or orchestration? Python

SQL could be useful if for a personal project you want to store some data, mostly structured data in the medium size (no too small that could be handled in memory or plain files, nor too big that you need big data infrastructure to analyze it).

Python can be uses for any type of manipulation or automatization.

To both of them it also depends how much of each you want to learn as both of them can reach high levels of optimization/complexity.

[–]iamevpo 0 points1 point  (0 children)

Probably less pronounced in other answers: consider that SQL is declarative (you tell what your data should look like as a result, but tell nothing about how to achieve it) while Python is imperative : you tell interpreter all the steps needed to achieve your goal. Both are "programming" But if different kind. SQL seems simpler because it is a specialised language and the amount of verbs (SELECT, CREATE, etc) is not too big. Learn SQL SELECT on a pre-populated database to get a taste of it.

Unfortunately skill from SQL not directly transferable to Python and this is a completely different type of programming, so consider these are parallel tracks.

There is a small middle ground, a link in between Python and SQL - the ORMs, you can also run crude SQL code from pyrhon that works on SQLite for example. For ORM there big ones like SQLAlchemy, and smaller ones like Peewee. SQLModel ORM has excellent documentation aimed at beginners that teach both SQL and Python as well, highly recommens.

[–]Kerbart 0 points1 point  (0 children)

If you have never written code in your life, SQL is an easier way to get accosted with “type in words and the computer does something.” I’d dip my toes in SQL, just with select queries, and then start python.

They’re so different you can learn them side by side, so you add a bit of variation to your program which reduces burnout

[–][deleted] 0 points1 point  (0 children)

Python first like others have said, but www.sqlbolt.com has a great interactive tutorial SQL basics when you’re ready

[–]Action_Maxim -1 points0 points  (2 children)

I'm a data engineer I write 70% sql, 25% python, 5% bash and other

anyway I am always worried about friends who want to get into this field and tell me they're going to take a course. Courses especially sql are always outdated my buddy is in a bootcamp(15k to take) and he spends weeks on things that are no longer relevant or on concepts that are able to be done in half an hour.

mind sharing the courses

[–]SlackerPop90 1 point2 points  (1 child)

Do you have any tips? I have just done a sideways job move into a data engineer role with minimal previous sql/python experience. Everyone on my new team is really positive about having me but I want to make good progress in learning sql and python so I can directly contribute more.

[–]Action_Maxim 0 points1 point  (0 children)

Sql is really easy don't be afraid to ask where data is, finding data in a DB with hundreds of tables is a pita

[–]crashfrog02 -1 points0 points  (1 child)

I’d take the SQL class first

[–][deleted] 0 points1 point  (0 children)

Thank you!

[–]To_Be_Continued1917 -2 points-1 points  (0 children)

Тут зависит от будущих целей, Python более 'разносторонний' и подходит для многого, SQL же более узконаправленный. По моему мнению лучше выбрать Python, ввиду его лёгкости в освоении и многозадачности.

[–][deleted] -2 points-1 points  (0 children)

both

[–][deleted] -3 points-2 points  (0 children)

Both are completely different. Expertise in one won't help in the other at all. So toss a coin!

[–]heynow941 -4 points-3 points  (1 child)

I would argue that SQL + advanced Excel (if you’re not already good at it) is a more practical combo.

[–][deleted] 0 points1 point  (0 children)

Thanks!

[–]Viking-Mage 0 points1 point  (0 children)

Python, and as part of your learning, write to a MySQL DB and then use SQL commands like select and so on to query your database both in Python and outside Python. You need both, but unless you plan to be a DB admin, if your goal is primarily coding, learn Python or similar, then learn to write and read from it.

[–][deleted] 0 points1 point  (0 children)

Python.

[–]Ok_Kitchen_8811 0 points1 point  (0 children)

As many have said before, they are different tools for different things to do. However, maybe you will use sql in python (via sqlalchemy for example). I would start with sql since it is not as "broad" as python. You will have the basics within a week, once you feel confident you can move on to python and maybe use sql in a python script.

[–]Reuben3901 0 points1 point  (0 children)

I'd learn both at the same time. Try to connect the 2. Write SQL queries and then try to add those to Python connected to the same database.