MySQL for Python and over one million other books are available for Amazon Kindle. Learn more

Vous voulez voir cette page en français ? Cliquez ici.


or
Sign in to turn on 1-Click ordering.
or
Amazon Prime Free Trial required. Sign up when you check out. Learn More
More Buying Choices
Have one to sell? Sell yours here
Start reading MySQL for Python on your Kindle in under a minute.

Don't have a Kindle? Get your Kindle here, or download a FREE Kindle Reading App.

MySQL for Python: Database Access Made Easy [Paperback]

Phd Albert Lukaszewski
5.0 out of 5 stars  See all reviews (1 customer review)
List Price: CDN$ 50.91
Price: CDN$ 50.35 & this item ships for FREE with Super Saver Shipping. Details
You Save: CDN$ 0.56 (1%)
o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
Only 1 left in stock (more on the way).
Ships from and sold by Amazon.ca. Gift-wrap available.
Want it delivered Thursday, May 23? Choose One-Day Shipping at checkout.

Formats

Amazon Price New from Used from
Kindle Edition CDN $16.65  
Paperback CDN $50.35  

Book Description

Sep 25 2010 1849510180 978-1849510189
Integrate the flexibility of Python and the power of MySQL to boost the productivity of your Python applications
  • Implement the outstanding features of Python's MySQL library to their full potential
  • See how to make MySQL take the processing burden from your programs
  • Learn how to employ Python with MySQL to power your websites and desktop applications
  • Apply your knowledge of MySQL and Python to real-world problems instead of hypothetical scenarios
  • A manual packed with step-by-step exercises to integrate your Python applications with the MySQL database server

In Detail

Python is a dynamic programming language, which is completely enterprise ready, owing largely to the variety of support modules that are available to extend its capabilities. In order to build productive and feature-rich Python applications, we need to use MySQL for Python, a module that provides database support to our applications. Although you might be familiar with accessing data in MySQL, here you will learn how to access data through MySQL for Python efficiently and effectively.

This book demonstrates how to boost the productivity of your Python applications by integrating them with the MySQL database server, the world's most powerful open source database. It will teach you to access the data on your MySQL database server easily with Python's library for MySQL using a practical, hands-on approach. Leaving theory to the classroom, this book uses real-world code to solve real-world problems with real-world solutions.

The book starts by exploring the various means of installing MySQL for Python on different platforms and how to use simple database querying techniques to improve your programs. It then takes you through data insertion, data retrieval, and error-handling techniques to create robust programs. The book also covers automation of both database and user creation, and administration of access controls. As the book progresses, you will learn to use many more advanced features of Python for MySQL that facilitate effective administration of your database through Python. Every chapter is illustrated with a project that you can deploy in your own situation.

By the end of this book, you will know several techniques for interfacing your Python applications with MySQL effectively so that powerful database management through Python becomes easy to achieve and easy to maintain.

A practical manual packed with step-by-step examples to manage your MySQL database efficiently through Python

What you will learn from this book

  • Explore the various means to install MySQL for Python, from using an egg to unrolling a tarball
  • Query the database and retrieve records through MySQL for Python
  • Implement insertion of data into a MySQL database in Python
  • Carry out error-handling in MySQL for Python in order to ensure the robustness of programs
  • Use secure logging techniques to record how your users use your programs
  • Carry out record-by-record retrieval to save a lot of overhead while retrieving data
  • Handle insertion of large amounts of data using iteration and the executemany function
  • Automate the creation and removal of databases and tables using MySQL for Python
  • Use the MySQL for Python library to automate user creation and to administer access controls
  • Log user activity with MySQL for Python by using MySQL's date and time support
  • See how to revise database programs to include more functionality
  • Use aggregate functions to make MySQL take the burden off your web server
  • Save time and processing resources by scripting JOINs and subqueries

Approach

This is a practical, tutorial-style book that includes many examples to demonstrate the full potential of MySQL for Python. Every chapter starts with an explanation of the various areas for using MySQL for Python and ends with work on a sample application using the programming calls just learned. All complicated concepts are broken down to be very easy to understand.

Everything in the book is designed to help you learn and use MySQL for Python to address your programming needs in the fastest way possible.

Who this book is written for

This book is meant for intermediate users of Python who want hassle-free access to their MySQL database through Python. If you are a Python programmer who wants database-support in your Python applications, then this book is for you. This book is a must-read for every focused user of the MySQL for Python library who wants real-world applications using this powerful combination of Python and MySQL.


Customers Who Bought This Item Also Bought


Product Details


Inside This Book (Learn More)
Browse Sample Pages
Front Cover | Copyright | Table of Contents | Excerpt | Back Cover
Search inside this book:

Customer Reviews

4 star
0
3 star
0
2 star
0
1 star
0
5.0 out of 5 stars
5.0 out of 5 stars
Most helpful customer reviews
5.0 out of 5 stars in depth examples Jan 25 2011
By M. Reid
Format:Paperback
I must say that I'm rather impressed at the variety of topics that the book covers.

It starts off with the basics of setting up MySQL for your testing/development needs by going over several of the common installation and configuration methods. After that it's a quick intro for connection methods and simple error reporting for connections. The author gives a quick intro to CRUD and how it relates to databases and python before heading into the common tasks of simple queries. I was surprised to see some database profiling discussion; which is rather handy for a new coder or a person new to MySQL. Once the basics of Inserts/Selects/Updates/Deletes are covered, which is a rather quick read, there is a welcome discussion of transactions and commit methods - if you do not read this section and are new to MySQL then believe me, you're missing a very important topic. Most people will gloss over the basics and head right to the more advanced chapters that feature exception handling, the all too common "the mysql server has gone away" error, date&time functions, aggregate functions, and metadata queries. These chapters were the most interesting to me as they covered some great code for python that I have not yet played around with. Previously I've done a lot of work on those topics with perl and php so seeing how they were done in python was a great treat. The code is concise, easy to read, and well explained.

A number of topics cover the time saving solutions that no one should be without. Namely, bulk data inserting, data formatting, row iteration, and CSV parsing. Logging methods for access and changes to the database are also covered, and in the end will save your development cycle a lot of time when you are troubleshooting app-to-db interaction.

Two chapters will be of interest to DBAs in particular, and possibly not as interesting to pure developers, of which these are the Disaster Recovery and MySQL Administration topics. The author covers offline backups as well as online hot backups, two sections that no DBA should be without. The code for this type of work is covered in a decent amount of discussion but, along with the other chapters in the book, the theory and background of the topic is also discussed which gives the new reader an understanding of "why" and not just left with the "how". The administration section of the book covers user creation and permissions management, along with a bit of background on security involved with that task, and also goes into quite a lot of coverage on web-based GUI administration and command line interaction for admin purposes.

Overall I enjoyed the contents of the book and would recommend taking a look if you are new to Python and MySQL or are even looking for a quick reference to the common tasks of database driven application development. This book does not cover the common ORM database interactions you're likely to see in an app like Django or Pylons, but it will give you a solid foundation on how python and MySQL interact without an abstraction layer. If you are writing quick admin code or building your own database interaction layer, then this book would do well to be in your collection.
Was this review helpful to you?
Most Helpful Customer Reviews on Amazon.com (beta)
Amazon.com: 3.5 out of 5 stars  6 reviews
8 of 8 people found the following review helpful
3.0 out of 5 stars Good for those new to MySQL and SQL, but has some issues Jan 26 2011
By Chris Sears - Published on Amazon.com
Format:Paperback
Based on the title, I was expecting in-depth coverage of Python's MySQL libraries, or at least for Python to be a main focus of the book. I was disappointed to find that the primary thing this book teaches is the SQL language and the coverage of Python was limited to the bare minimum needed to run the SQL examples. And although it does touch on some of the SQL language elements unique to MySQL, most of the content is standard SQL that would work on many different databases.

If you are new to SQL and are developing non-web applications, using MySQL for a database and Python as your programming language, this book may be valuable to you. If instead, you already know SQL and especially if you are developing web applications, this is not the book for you. I mainly fault the book for claiming too broad of an audience and omitting some important concepts.

Here are some of the major issues:

1. The book never makes the distinction between SQL (the language), MySQL (the database server/DBMS), and MySQL's proprietary SQL extensions. These are important concepts to understand. If this was your first exposure to the SQL language, you would leave with some significant knowledge gaps.

2. The only MySQL library covered is the aging MySQLdb, aka mysql-python. This is the default MySQL library that ships with Python, but there are other libraries, such as SQLalchemy or oursql, which at least deserved to be mentioned.

3. Perhaps the most serious omission is that SQL injection attacks are never covered and throughout the book the example code construct SQL statement strings in a way that could easily be exploited in a web application environment.

4. My jaw dropped when chapter 7 introduced a web-enabled MySQL administration example explained that CGI and PHP were good options for exposing a Python app over the web. That may have been true 10 years ago, but no one would use either in a modern Python web application. Any rational developer would use a web-app framework like Django, which include a nice database abstraction or ORM library - none of which ever get mentioned. The PHP example actually recommends running Python script using the (PHP) shell_exec() function. This sort of thing has no place in a Python book.

5. The book says its examples were written for Python 2.5.2, which was released in Feburary 2008 and later found to have security bugs. I expect most people are smart enough not to blindly go download version 2.5.2, but I would have prefered they mention version 2.5.5 (release January 2010) which fixed the security issues. Better still would have been to target a more modern, mainstream version of Python, like 2.6 or 2.7.

6. In chapter 7, as the book introduces HTML, it mentions the web site W3Schools as "one of the best" sources for HTML tutorials. This could not be more wrong. W3Schools is quite dated and contains many horrible examples that anyone new to modern web development would want to avoid like the plague. It unfortunately shows up at the top of many Google searches, so it gets cited frequently. That may sound trivial, but to me, this is further indication that the author has very limited experience with developing apps for web environments.

In summary, I felt the book did not live up to its title or the various descriptions of its audience and scope. It does contain some good information and would certainly help novice Python programmers needing a broad introduction to using SQL, MySQL and the Python MySQLdb library. Unfortunately, I suspect that most "intermediate Python programmers" (which the book claims to target) will already know enough SQL and MySQL that this would be a disappointing read.

(I would note that I was provided a free ebook copy this title and was invited to provide feedback.)
2 of 2 people found the following review helpful
4.0 out of 5 stars Great MySQL and Python Reference Dec 26 2010
By Eric B. Lubow - Published on Amazon.com
Format:Paperback
I am always for using the right tool for the right job. A lot of time, that tool is Python. I have always had trouble finding solid documentation on using MySQL with Python. There was generally enough to get by, but the more the merrier. Enter MySQL for Python by Albert Lukaszewski.

As I mention in most of my reviews, on the of the things I love about Packt Publishing books is that they typically follow the same pattern: installation, teaching, project, summary. And my favorite piece is the mini projects given at the end of each chapter. It's a little reality check for the reader reminding them that everything that they are doing has a real life application.

So skipping the installation chapter and jumping right in to the teaching, there is a lot of discussion about how to do the common stuff that one does in MySQL through Python. If you have a lot of experience with MySQL, then this is a handy reference. I also really like the fact that scattered throughout the book is information on becoming a better programmer (like tradeoffs on memory efficiency vs. performance).

Chapter 4 contained information about exception handling. Just like previous chapters, the amount of information on the handling of warnings and exceptions exceeds the boundaries of just MySQL in Python. This was a great review for any Python programmer. No need for further discussion as this chapter is available from Packt Publishing here.

The next few chapters deal with data manipulation in Python. This includes INSERTs, UPDATEs, DELETEs, etc. Chapter 8 specifically deals with user management in MySQL. This is a great skill to have regardless of the interface that you are using to tie into MySQL. Most programmers neglect the concept of administration and leave it to the DBAs or the SysAdmins. Albert takes the reader through some admin exercises including user management, backup and recovery, and accessing the MySQL meta information like information_schema tables. There was also discussion about the various storage engines which was unexpected.

Bouncing backwards a little was a lesson on the string and aggregation functions built into MySQL. A lot of these capabilities are usually handled programatically and not off-loaded to the database like it should be. Again, this is a great refresher (or even initial) lesson for any programmer who spends a lot of time building and maintaining complex queries.

Overall this book was another great teaching tool put forth by the folks at Packt. The audience is definitely not at the beginner Python programmer, but an intermediate level developer would have no issues understanding everything. You can find this book either at Amazon or directly from Packt Publishing.
1 of 1 people found the following review helpful
4.0 out of 5 stars Where to start with SQL programming if you're already familiar with Python Feb 4 2011
By Bryce Verdier - Published on Amazon.com
Format:Paperback
want or need to get their minds and hands on a crash course in SQL programming and MySQL administration.

I base the opinion above on the fact that I am someone who is comfortable with Python, but does not code in it often during my job. I am also someone who can work his way around a MySQL database without having to research every SQL command; my knowledge of Python and MySQL is functional, but not expert.

The book's format is one that I would think someone who didn't know what they were doing with MySQL would find helpful. Each chapter is dedicated to performing a certain set of MySQL tasks; for example Chapter 7 is titled "Creating and Dropping" (as in tables). The chapter opens with a quick discussion about what information the chapter is supposed to convey. Then it moves on to which commands one will use in MySQL to perform the desired tasks. After these commands are discussed, the book then goes into how to perform the same commands in Python. Each chapter ends with a project that is supposed to challenge the reader to create something that exemplifies the chapter's topic.

One area where I find the book lacking is that there is no mention of Python3 or the changes that one's code would require to make it compatible with Python3 vs Python. For example, there are a couple of code examples in the book that heavily rely on the function xrange(). Not that xrange() is bad function to use, but that particular function doesn't exist in Python 3. I could theorize that maybe the author didn't want to complicate the idea of using Python as a tool to learning SQL, but it does limit the amount of time that the content stays relevant.

A part of the book that I did find quite good was the quick and easily understandable explanation of the various join functions in Chapter 13. Although the descriptions were a little short, the brevity was acceptable because of the included Venn diagrams to help illustrate the how the joins worked logically. This was a great touch for helping someone learn these concepts; it was also the first time I've seen Venn diagrams used to teach someone about joins.

I recognize I might have been overly harsh on this book review, but that doesn't mean I wouldn't recommend it for the right person. I feel the right person for this is someone who is already comfortable with Python and wants to expand their knowledge to include the basics of MySQL administration and SQL programming.
Search Customer Reviews
Only search this product's reviews

Listmania!

Create a Listmania! list

Look for similar items by category


Feedback


Amazon.ca Privacy Statement Amazon.ca Shipping Information Amazon.ca Returns & Exchanges