Kategorie
Ebooki
-
Biznes i ekonomia
- Bitcoin
- Bizneswoman
- Coaching
- Controlling
- E-biznes
- Ekonomia
- Finanse
- Giełda i inwestycje
- Kompetencje osobiste
- Komputer w biurze
- Komunikacja i negocjacje
- Mała firma
- Marketing
- Motywacja
- Multimedialne szkolenia
- Nieruchomości
- Perswazja i NLP
- Podatki
- Polityka społeczna
- Poradniki
- Prezentacje
- Przywództwo
- Public Relation
- Raporty, analizy
- Sekret
- Social Media
- Sprzedaż
- Start-up
- Twoja kariera
- Zarządzanie
- Zarządzanie projektami
- Zasoby ludzkie (HR)
-
Dla dzieci
-
Dla młodzieży
-
Edukacja
-
Encyklopedie, słowniki
-
E-prasa
- Architektura i wnętrza
- Biznes i Ekonomia
- Dom i ogród
- E-Biznes
- Finanse
- Finanse osobiste
- Firma
- Fotografia
- Informatyka
- Kadry i płace
- Komputery, Excel
- Księgowość
- Kultura i literatura
- Naukowe i akademickie
- Ochrona środowiska
- Opiniotwórcze
- Oświata
- Podatki
- Podróże
- Psychologia
- Religia
- Rolnictwo
- Rynek książki i prasy
- Transport i Spedycja
- Zdrowie i uroda
-
Historia
-
Informatyka
- Aplikacje biurowe
- Bazy danych
- Bioinformatyka
- Biznes IT
- CAD/CAM
- Digital Lifestyle
- DTP
- Elektronika
- Fotografia cyfrowa
- Grafika komputerowa
- Gry
- Hacking
- Hardware
- IT w ekonomii
- Pakiety naukowe
- Podręczniki szkolne
- Podstawy komputera
- Programowanie
- Programowanie mobilne
- Serwery internetowe
- Sieci komputerowe
- Start-up
- Systemy operacyjne
- Sztuczna inteligencja
- Technologia dla dzieci
- Webmasterstwo
-
Inne
-
Języki obce
-
Kultura i sztuka
-
Lektury szkolne
-
Literatura
- Antologie
- Ballada
- Biografie i autobiografie
- Dla dorosłych
- Dramat
- Dzienniki, pamiętniki, listy
- Epos, epopeja
- Esej
- Fantastyka i science-fiction
- Felietony
- Fikcja
- Humor, satyra
- Inne
- Klasyczna
- Kryminał
- Literatura faktu
- Literatura piękna
- Mity i legendy
- Nobliści
- Nowele
- Obyczajowa
- Okultyzm i magia
- Opowiadania
- Pamiętniki
- Podróże
- Poemat
- Poezja
- Polityka
- Popularnonaukowa
- Powieść
- Powieść historyczna
- Proza
- Przygodowa
- Publicystyka
- Reportaż
- Romans i literatura obyczajowa
- Sensacja
- Thriller, Horror
- Wywiady i wspomnienia
-
Nauki przyrodnicze
-
Nauki społeczne
-
Podręczniki szkolne
-
Popularnonaukowe i akademickie
- Archeologia
- Bibliotekoznawstwo
- Filmoznawstwo
- Filologia
- Filologia polska
- Filozofia
- Finanse i bankowość
- Geografia
- Gospodarka
- Handel. Gospodarka światowa
- Historia i archeologia
- Historia sztuki i architektury
- Kulturoznawstwo
- Lingwistyka
- Literaturoznawstwo
- Logistyka
- Matematyka
- Medycyna
- Nauki humanistyczne
- Pedagogika
- Pomoce naukowe
- Popularnonaukowa
- Pozostałe
- Psychologia
- Socjologia
- Teatrologia
- Teologia
- Teorie i nauki ekonomiczne
- Transport i spedycja
- Wychowanie fizyczne
- Zarządzanie i marketing
-
Poradniki
-
Poradniki do gier
-
Poradniki zawodowe i specjalistyczne
-
Prawo
- BHP
- Historia
- Kodeks drogowy. Prawo jazdy
- Nauki prawne
- Ochrona zdrowia
- Ogólne, kompendium wiedzy
- Podręczniki akademickie
- Pozostałe
- Prawo budowlane i lokalowe
- Prawo cywilne
- Prawo finansowe
- Prawo gospodarcze
- Prawo gospodarcze i handlowe
- Prawo karne
- Prawo karne. Przestępstwa karne. Kryminologia
- Prawo międzynarodowe
- Prawo międzynarodowe i zagraniczne
- Prawo ochrony zdrowia
- Prawo oświatowe
- Prawo podatkowe
- Prawo pracy i ubezpieczeń społecznych
- Prawo publiczne, konstytucyjne i administracyjne
- Prawo rodzinne i opiekuńcze
- Prawo rolne
- Prawo socjalne, prawo pracy
- Prawo Unii Europejskiej
- Przemysł
- Rolne i ochrona środowiska
- Słowniki i encyklopedie
- Zamówienia publiczne
- Zarządzanie
-
Przewodniki i podróże
- Afryka
- Albumy
- Ameryka Południowa
- Ameryka Środkowa i Północna
- Australia, Nowa Zelandia, Oceania
- Austria
- Azja
- Bałkany
- Bliski Wschód
- Bułgaria
- Chiny
- Chorwacja
- Czechy
- Dania
- Egipt
- Estonia
- Europa
- Francja
- Góry
- Grecja
- Hiszpania
- Holandia
- Islandia
- Litwa
- Łotwa
- Mapy, Plany miast, Atlasy
- Miniprzewodniki
- Niemcy
- Norwegia
- Podróże aktywne
- Polska
- Portugalia
- Pozostałe
- Rosja
- Rumunia
- Słowacja
- Słowenia
- Szwajcaria
- Szwecja
- Świat
- Turcja
- Ukraina
- Węgry
- Wielka Brytania
- Włochy
-
Psychologia
- Filozofie życiowe
- Kompetencje psychospołeczne
- Komunikacja międzyludzka
- Mindfulness
- Ogólne
- Perswazja i NLP
- Psychologia akademicka
- Psychologia duszy i umysłu
- Psychologia pracy
- Relacje i związki
- Rodzicielstwo i psychologia dziecka
- Rozwiązywanie problemów
- Rozwój intelektualny
- Sekret
- Seksualność
- Uwodzenie
- Wygląd i wizerunek
- Życiowe filozofie
-
Religia
-
Sport, fitness, diety
-
Technika i mechanika
Audiobooki
-
Biznes i ekonomia
- Bitcoin
- Bizneswoman
- Coaching
- Controlling
- E-biznes
- Ekonomia
- Finanse
- Giełda i inwestycje
- Kompetencje osobiste
- Komunikacja i negocjacje
- Mała firma
- Marketing
- Motywacja
- Nieruchomości
- Perswazja i NLP
- Podatki
- Poradniki
- Prezentacje
- Przywództwo
- Public Relation
- Sekret
- Social Media
- Sprzedaż
- Start-up
- Twoja kariera
- Zarządzanie
- Zarządzanie projektami
- Zasoby ludzkie (HR)
-
Dla dzieci
-
Dla młodzieży
-
Edukacja
-
Encyklopedie, słowniki
-
Historia
-
Informatyka
-
Inne
-
Języki obce
-
Kultura i sztuka
-
Lektury szkolne
-
Literatura
- Antologie
- Ballada
- Biografie i autobiografie
- Dla dorosłych
- Dramat
- Dzienniki, pamiętniki, listy
- Epos, epopeja
- Esej
- Fantastyka i science-fiction
- Felietony
- Fikcja
- Humor, satyra
- Inne
- Klasyczna
- Kryminał
- Literatura faktu
- Literatura piękna
- Mity i legendy
- Nobliści
- Nowele
- Obyczajowa
- Okultyzm i magia
- Opowiadania
- Pamiętniki
- Podróże
- Poezja
- Polityka
- Popularnonaukowa
- Powieść
- Powieść historyczna
- Proza
- Przygodowa
- Publicystyka
- Reportaż
- Romans i literatura obyczajowa
- Sensacja
- Thriller, Horror
- Wywiady i wspomnienia
-
Nauki przyrodnicze
-
Nauki społeczne
-
Popularnonaukowe i akademickie
-
Poradniki
-
Poradniki zawodowe i specjalistyczne
-
Prawo
-
Przewodniki i podróże
-
Psychologia
- Filozofie życiowe
- Komunikacja międzyludzka
- Mindfulness
- Ogólne
- Perswazja i NLP
- Psychologia akademicka
- Psychologia duszy i umysłu
- Psychologia pracy
- Relacje i związki
- Rodzicielstwo i psychologia dziecka
- Rozwiązywanie problemów
- Rozwój intelektualny
- Sekret
- Seksualność
- Uwodzenie
- Wygląd i wizerunek
- Życiowe filozofie
-
Religia
-
Sport, fitness, diety
-
Technika i mechanika
Kursy video
-
Bazy danych
-
Big Data
-
Biznes, ekonomia i marketing
-
Cyberbezpieczeństwo
-
Data Science
-
DevOps
-
Dla dzieci
-
Elektronika
-
Grafika/Wideo/CAX
-
Gry
-
Microsoft Office
-
Narzędzia programistyczne
-
Programowanie
-
Rozwój osobisty
-
Sieci komputerowe
-
Systemy operacyjne
-
Testowanie oprogramowania
-
Urządzenia mobilne
-
UX/UI
-
Web development
-
Zarządzanie
Podcasty
- Ebooki
- Programowanie
- Python
- MySQL for Python. Integrating MySQL and Python can bring a whole new level of productivity to your applications. This practical tutorial shows you how with examples and explanations that clarify even the most difficult concepts
Szczegóły ebooka
Zaloguj się, jeśli jesteś zainteresowany treścią pozycji.
MySQL for Python. Integrating MySQL and Python can bring a whole new level of productivity to your applications. This practical tutorial shows you how with examples and explanations that clarify even the most difficult concepts
Ebook
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.
- MySQL for Python
- Table of Contents
- MySQL for Python
- Credits
- About the Author
- About the Reviewers
- Preface
- What this book covers
- What you need for this book
- Who this book is for
- Conventions
- Reader feedback
- Customer support
- Errata
- Piracy
- Questions
- 1. Getting Up and Running with MySQL for Python
- Getting MySQL for Python
- Using a package manager (only on Linux)
- Using RPMs and yum
- Using RPMs and urpm
- Using apt tools on Debian-like systems
- Using an installer for Windows
- Using an egg file
- Installing egg handling software
- Using a package manager (Linux)
- Without a package manager (Mac, Linux)
- On Microsoft Windows
- Installing MySQL for Python from an egg file
- Installing egg handling software
- Using a tarball (tar.gz file)
- Using a package manager (only on Linux)
- Importing MySQL for Python
- Accessing online help when you need it
- MySQLdb
- _mysql
- Connecting with a database
- Creating a connection object
- Creating a cursor object
- Interacting with the database
- Closing the connection
- Multiple database connections
- Summary
- Getting MySQL for Python
- 2. Simple Querying
- A brief introduction to CRUD
- Forming a query in MySQL
- SELECT
- * (asterisk)
- FROM
- staff
- ; (semicolon)
- Other helpful quantifiers
- WHERE
- GROUP BY
- HAVING
- ORDER BY
- LIMIT
- INTO OUTFILE
- Passing a query to MySQL
- A simple SELECT statement
- Modifying the results
- Using user-defined variables
- Determining characteristics of a database and its tables
- Determining what tables exist
- Assigning each table a number
- Offering the options to the user
- Allowing the user to detail a search query
- Changing queries dynamically
- Pattern matching in MySQL queries
- Putting it into practice
- Project: A command-line search utility
- Preparing a database for searching
- Planning your work, then working your plan
- Develop a well-abstracted search functionality
- Specifying the search term from the command-line
- Implementing and incorporating the other functions: -t, -f, and -o
- Including an option for an output file
- Room to grow
- Summary
- 3. Simple Insertion
- Forming a MySQL insertion statement
- INSERT
- INTO
- Table name
- Column names
- VALUES
- <some values>
- ; (semicolon)
- Helpful ways to nuance an INSERT statement
- INSERT...SELECT...
- INSERT DELAYED
- INSERT...ON DUPLICATE KEY UPDATE...
- Passing an insertion through MySQL for Python
- Setting up the preliminaries
- A simple INSERT statement
- More complex INSERT commands
- Using user-defined variables
- Using metadata
- Querying the database for its structure
- Retrieving the table structure
- Changing insertion values dynamically
- Validating the value of name
- Validating the value of price
- Querying the user for a correction
- Passing fish and price for validation
- Essentials: close and commit
- In need of some closure
- What happened to commit?
- Why are these essentials non-essential?
- Project: A command-line insertion utility
- The necessary modules
- The main() thing
- Coding the flag system
- Testing the values passed by the user
- Try to establish a database connection
- Showing the tables
- Showing the table structure, if desired
- Accepting user input for the INSERT statement
- Building the INSERT statement from the user input and executing it
- Committing changes and closing the connection
- Coding the other functions
- valid_digit() and valid_string()
- valid_table()
- query()
- Calling main()
- Room to grow
- Summary
- Forming a MySQL insertion statement
- 4. Exception Handling
- Why errors and warnings are good for you
- Errors versus warnings: Theres a big difference
- The two main errors in MySQLdb
- DatabaseError
- InterfaceError
- Warnings in MySQL for Python
- Handling exceptions passed from MySQL
- Python exception-handling
- Catching an exception from MySQLdb
- Raising an error or a warning
- Making exceptions less intimidating
- Catching different types of exceptions
- Types of errors
- DataError
- IntegrityError
- InternalError
- NotSupportedError
- OperationalError
- ProgrammingError
- Customizing for catching
- Catching one type of exception
- Catching different exceptions
- Combined catching of exceptions
- Raising different exceptions
- Types of errors
- Creating a feedback loop
- Project: Bad apples
- The preamble
- Making the connection
- Sending error messages
- The statement class
- The __init__ method
- Storing the statement type
- Forming the statement
- Execute the MySQL statement
- Handling any fallout
- The statement class
- The main() thing
- Try, try again
- If all else fails
- Room to grow
- Summary
- 5. Results Record-by-Record
- The problem
- Why?
- Computing resources
- Local resources
- Web applications
- Network latency
- Server-client communications
- Apparent responsiveness
- Pareto's Principle
- Computing resources
- How?
- The fetchone() method
- The fetchmany() method
- Iteration: What is it?
- Generating loops
- while...if loops
- The for loop
- Iterators
- Illustrative iteration
- Iteration and MySQL for Python
- Generators
- Using fetchone() in a generator
- Using fetchmany() in a generator
- Project: A movie database
- Getting Sakila
- Creating the Sakila database
- The structure of Sakila
- Planning it out
- The SQL statements to be used
- Returning the films of an actor
- Returning the actors of a film
- Accepting user data
- A MySQL query with class
- The __init__ method: The consciousness of the class
- Setting the query's type
- Creating the cursor
- Forming the query
- Executing the query
- Formatting the results
- Formatting a sample
- Formatting a larger set of results
- The main() thing
- Calling main()
- Running it
- Room to grow
- Summary
- 6. Inserting Multiple Entries
- The problem
- Why not a MySQL script?
- Lack of automation
- Debugging the process
- Inefficient I/O
- Why not iterate?
- A test sample: Generating primes
- Comparing execution speeds
- Why not a MySQL script?
- Introducing the executemany() method
- executemany(): Basic syntax
- executemany(): Multiple INSERT statements
- executemany(): multiple SELECT statements
- executemany(): Behind the scenes
- MySQL server has gone away
- Command-line option configuration
- Using a configuration file
- More than 16 MB is often unnecessary
- MySQL server has gone away
- Project: Converting a CSV file to a MySQL table
- The preamble
- The options
- Defining the connection
- Creating convert
- The main() function
- Calling main()
- Room to grow
- Summary
- The problem
- 7. Creating and Dropping
- Creating databases
- Test first, create second
- CREATE specifications
- Specifying the default character set
- Specifying the collation for a database
- Declaring collation
- Finding available character sets and collations
- Removing or deleting databases
- Avoiding errors
- Preventing (illegal) access after a DROP
- Creating tables
- Covering our bases
- Avoiding errors
- Creating temporary tables
- Dropping tables
- Playing it safe
- Avoiding errors
- Removing user privileges
- Doing it in Python
- Creating databases with MySQLdb
- Testing the output
- Dynamically configuring the CREATE statement
- Dropping databases with MySQLdb
- Creating tables in Python
- Verifying the creation of a table
- Another way to verify table creation
- Creating databases with MySQLdb
- Dropping tables with MySQLdb
- Project: Web-based administration of MySQL
- CGI vs PHP: What is the difference?
- Basic CGI
- Using PHP as a substitute for CGI
- CGI versus PHP: When to use which?
- Some general considerations for this program
- Program flow
- The basic menu
- Authorization details
- Three operational sections of the dialogue
- The variables
- Planning the functions
- Code of each function
- Connecting without a database
- Connecting with a database
- Database action
- Table action
- Query action
- execute()
- The HTML output
- Basic definition
- The message attribute
- Defining header()
- Defining footer()
- Defining body()
- Defining page()
- Getting the data
- Using CGI
- Using PHP
- Defining main()
- Room to grow
- Summary
- Creating databases
- 8. Creating Users and Granting Access
- A word on security
- Creating users in MySQL
- Forcing the use of a password
- Restricting the client's host
- Creating users from Python
- Removing users in MySQL
- DROPping users in Python
- GRANT access in MySQL
- Important dynamics of GRANTing access
- The GRANT statement in MySQL
- Using REQUIREments of access
- Using a WITH clause
- Granting access in Python
- Removing privileges in MySQL
- Basic syntax
- After using REVOKE, the user still has access!?
- Using REVOKE in Python
- Project: Web-based user administration
- New options in the code
- Adding the functions: CREATE and DROP
- Adding CREATE and DROP to main()
- Adding the functions: GRANT and REVOKE
- Adding GRANT and REVOKE to main()
- Test the program
- New options on the page
- Room to grow
- Summary
- 9. Date and Time Values
- Date and time data types in MySQL
- DATETIME
- Output format
- Input formats
- Input range
- Using DATETIME in a CREATE statement
- DATE
- Output and Input formats
- Input range
- TIMESTAMP
- Input of values
- Range
- Defaults, initialization, and updating
- YEAR
- Two-digit YEAR values
- Four-digit YEAR values
- Valid input
- TIME
- Format
- Invalid values
- DATETIME
- Date and time types in Python
- Date and time functions
- NOW()
- CURDATE()
- CURTIME()
- DATE()
- DATE_SUB() and DATE_ADD()
- DATEDIFF()
- DATE_FORMAT()
- EXTRACT()
- TIME()
- Project: Logging user activity
- The log framework
- The logger() function
- Creating the database
- Using the database
- Creating the table
- Forming the INSERT statement
- Ensure logging occurs
- Room to grow
- Summary
- Date and time data types in MySQL
- 10. Aggregate Functions and Clauses
- Calculations in MySQL
- COUNT()
- SUM()
- MAX()
- MIN()
- AVG()
- The different kinds of average
- Mean
- Median
- Mode
- The different kinds of average
- Trimming results
- DISTINCT
- GROUP_CONCAT()
- Specifying the delimiter
- Customizing the maximum length
- Using GROUP_CONCAT() with DISTINCT
- Server-side sorting in MySQL
- GROUP BY
- ORDER BY
- Using a universal quantifier
- Sorting alphabetically or from low-to-high
- Reversing the alphabet or sorting high-to-low
- Sorting with multiple keys
- Putting it in Python
- Project: Incorporating aggregate functions
- Adding to qaction()
- New variables
- New statement formation
- Revising main()
- Setting up the options
- Changing the HTML form
- Adding to qaction()
- Summary
- Calculations in MySQL
- 11. SELECT Alternatives
- HAVING clause
- WHERE versus HAVING: Syntax
- WHERE versus HAVING: Aggregate functions
- WHERE versus HAVING: Application
- Subqueries
- Unions
- Joins
- LEFT and RIGHT joins
- OUTER joins
- INNER joins
- NATURAL joins
- CROSS joins
- Doing it in Python
- Subqueries
- Unions
- Joins
- Project: Implement HAVING
- Revising the Python backend
- Revising qaction()
- Revising main()
- Revising the options
- Revising the HTML interface
- Room to grow
- Revising the Python backend
- Summary
- HAVING clause
- 12. String Functions
- Preparing results before their return
- CONCAT() function
- SUBSTRING() or MID()
- TRIM()
- Basic syntax
- Options
- Alternatives
- REPLACE()
- INSERT()
- REGEXP
- Accessing and using index data
- LENGTH()
- INSTR() or LOCATE()
- INSTR()
- LOCATE()
- Nuancing data
- ROUND()
- FORMAT()
- UPPER()
- LOWER()
- Project: Creating your own functions
- Hello()
- Capitalise()
- DELIMITER
- The function definition
- Calling the function
- Defining the function in Python
- Defining the function as a Python value
- Sourcing the MySQL function as a Python module
- Sourcing the function as MySQL code
- Room to grow
- Summary
- Preparing results before their return
- 13. Showing MySQL Metadata
- MySQL's system environment
- ENGINE
- The most popular engines
- Transactions
- Specifying the engine
- ENGINE status
- SHOW ENGINES
- Profiling
- SHOW PROFILE
- SHOW PROFILES
- SHOW system variables
- ENGINE
- Accessing database metadata
- DATABASES
- Using the USE command
- Accessing metadata about tables
- SHOW TABLES
- SHOW TABLE STATUS
- Showing columns from a table
- FUNCTION STATUS
- CREATE (DATABASE/FUNCTION/PROCEDURE/TABLE/VIEW)
- DATABASES
- Accessing user metadata
- SHOW GRANTS
- PRIVILEGES
- Project: Building a database class
- Writing the class
- Defining fetchquery() and some core methods
- Retrieving table status and structure
- Retrieving the CREATE statements
- Define main()part 1
- Writing resproc()
- Define main()part 2
- The preamble
- Modules and variables
- Login and USE
- Closing out the program
- Room to grow
- Writing the class
- Summary
- MySQL's system environment
- 14. Disaster Recovery
- Every database needs a backup plan
- Offline backups
- Live backups
- Choosing a backup method
- Copying the table files
- Locking and flushing
- LOCK TABLES
- FLUSH
- Unlocking the tables
- Restoring the data
- Locking and flushing
- Delimited backups within MySQL
- Using SELECT INTO OUTFILE to export data
- Using LOAD DATA INFILE to import data
- Archiving from the command line
- mysqldump
- Viewing the backup file
- Other options
- Restoring the data
- mysqlhotcopy
- mysqldump
- Copying the table files
- Backing up a database with Python
- Summary
- Every database needs a backup plan
- Index
- Tytuł: MySQL for Python. Integrating MySQL and Python can bring a whole new level of productivity to your applications. This practical tutorial shows you how with examples and explanations that clarify even the most difficult concepts
- Autor: Albert Lukaszewski
- Tytuł oryginału: MySQL for Python. Integrating MySQL and Python can bring a whole new level of productivity to your applications. This practical tutorial shows you how with examples and explanations that clarify even the most difficult concepts.
- ISBN: 9781849510196, 9781849510196
- Data wydania: 2010-09-21
- Format: Ebook
- Identyfikator pozycji: e_2x3s
- Wydawca: Packt Publishing