Beginning MySQL/Python
I have just begun learning Python. Eventually I will learn Django, as my goal is to able to do web development (video sharing/social networking). At which point should I begin learning MySQL? Do I need to know it before I even begin Django? If so, how much should I look to know before diving into Django? T开发者_Go百科hank you.
Having some ideas of what's going on in ANY database will help you with your web programming endeavours. You're best bet is to spend some time learning basic SQL just using SQLite (it comes with python) and moving what's known as an ORM (Object Relational Mapper) such as SQLAlchemy
The current trends point towards most web based application using some form of ORM between their application and the database. The ORM provides a level of abstraction so you don't have to know specific details of how the database works, the ORM handles it for you. The benefit of this is that you can change databases without having any major impact.
You DO however want to build a foundation in basic SQL statements. SELECT, INSERT, WHERE, etc. I've pointed many people to sqlzoo's tutorial as it's excellent.
http://sqlzoo.net/
Django uses its own ORM, so I guess it's not completely necessary to learn MySQL first, but I suspect it would help a fair bit to know what's going on behind the scenes, and it will help you think in the correct way to formulate your queries.
I would start learning MySQL (or any other SQL), after you've got a pretty good grip on Python, but probably before you start learning Django, or perhaps alongside. You won't need a thorough understanding of SQL. At least, not to get started.
Err... ORM/Object Relational Mapper, it hides/abstracts the complexities of SQL and lets you access your data through the simple objects/models you define in Python. For example, you might have a "Person" model with Name, Age, etc. That Name and Age could be stored and retrieved from the database transparently just be accessing the object, without having to write any SQL. (Just a simple .save() and .get())
I'll second Kurt's reply that it's a good idea to build a foundation in basic SQL. That skill will come in handy whether you end up using MySQL, Access, Oracle, or another relational database. My favorite SQL tutorial site is at http://www.1keydata.com/sql/sql.html.
As Django documents somehow Recommends, It is better to learning PostgreSQL.
PostgreSQL is working pretty with Django, I never had any problem with Django/PostgreSQL. I all know is sometimes i have weird error when working with MySQL.
精彩评论