Python with Django and MySQL
The Python programming language was developed in the early 1990s by the Dutchman Guido van Rossum at the Centrum voor Wiskunde en Informatica (CWI) in Amsterdam. The name Python is not inspired by the family of snakes, but by the British comedy troupe Monty Python. It is a programming language that is both powerful and easy to learn, and according to some statistics it is on its way to overtaking Java in terms of popularity and traffic. Python is a multiparadigm programming language. It is possible, for example, to program in Python in an object-oriented as well as a functional style. Python programs are independent of the platform on which they are run, in particular Windows, Linux or macOS. The Python standard library is very extensive; it offers a wide range of tools, from the most basic, for example for text manipulation, file access and mathematical operations, to the most sophisticated, for example for network communication or data storage. A good number of fast-growing companies use, at least in part, Python for the development of their programs or Web applications (Gmail, Google Maps, YouTube, Dropbox, etc.). We can therefore say that Python is a popular, widely used and modern programming language that is certainly worth learning. This book is a translation of a previously published French edition, with certain corrections made to the French version. The translation was done largely with the help of Claude, Anthropic's artificial intelligence assistant. The aim of this book is to introduce Python to developers and students who are already familiar with other programming languages, and to provide professionals with a reference they can turn to whenever the need arises. In the first chapter, we begin by stating the advantages of the Python programming language and listing the main development environments for Python. We have devoted the second chapter to a description of the installation of Python. In the third chapter we develop our first application, a Python script that displays the message Hello World! The elements common to all programming languages (data and operators, control structures) are covered in the fourth and fifth chapters. The aspect of object-oriented programming (OOP) in Python is covered in the sixth chapter. It is in this chapter that we present the notions of class, method, constructor and destructor, instantiation, inheritance, etc. The processing of files and directories, for its part, is described in the seventh chapter. The advanced concepts, intended for readers who will already be thoroughly familiar with the basic concepts, are the subject of the eighth chapter: numerous examples will make it possible to grasp clearly the notions of iterators, generators, closures, decorators, etc. Access from Python to data stored in a database is the subject of the ninth chapter. The choice of the Database Management System (DBMS) MySQL to address this aspect is not fortuitous, since MySQL is one of the most widespread DBMSs in the world. It is a piece of software, available in both an open source and a commercial version, which can run on many operating systems. Python of course has a library that makes it possible, by converting data types, to integrate the two: Python and MySQL. In this ninth chapter we describe the installation of the MySQL DBMS as well as its administration and development tools. We have also described in this chapter the compilation of the free software XAMPP, which contains the MySQL DBMS and makes it possible to install and configure it quickly. In this chapter we study access to a MySQL database from a Python script and the insertion, in a Python script, of SQL commands (Structured Query Language) with their various clauses, whether the commands relate to a data definition or to a data manipulation. The eleventh chapter is entirely devoted to the Django web development environment. Django is to Python what Symfony is to PHP. Its ability to implement projects quickly and efficiently means that it is considered “intended for perfectionists who want to manage their time optimally”. With Django, structured according to the Model-Template-View (MTV) pattern, itself based on the well- known Model-View-Controller (MVC) pattern, the developer adheres to the DRY principle (don’t repeat yourself - avoid repetition). Django appears today as an optimal solution for an MVP design (Minimum Viable Product - the smallest viable product). Many start-ups today choose the MVP model to develop an initial piece of software, and the MVP design can be implemented, with the Django framework, in an optimal way. It is available there and ready to use. The architecture of a Django application is described in this eleventh chapter, as well as the administration application contained in Django. An example of developing a web application, step by step, is given in this chapter. The reserved words as well as the naming conventions, useful for easy maintenance of programs or for their extensions, are given at the end of the book. After that will be found a description of the most commonly used HTML tags, solved exercises, as well as the answers to the multiple-choice questions offered at the end of each chapter. To make this book easy to read, different fonts have been used to distinguish its text from the Python code given in the examples and exercises.
Avis des lecteurs
Aucun avis pour le moment.