Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

What is MySQL?

ABOUT MYSQL

The management of data in a database system is done by means of a general-


purpose software package called a Database Management System (DBMS). Some
commercially available RDBMS are MS SQL Server, MS ACCESS, INGRES, ORACLE,
and Sybase. MySQL, the most popular Open Source SQL database management
system, is developed, distributed, and supported by Oracle Corporation. MySQL is
named after co-founder Monty Widenius's daughter, My. The name of the MySQL
Dolphin (logo) is "Sakila".

 MySQL is a database management

A database is a structured collection of data. It may be anything from a simple


shopping list to a picture gallery or the vast amounts of information in a corporate
network. To add, access, and process data stored in a computer database, you
need a database management system such as MySQL Server. Since computers are
very good at handling large amounts of data, database management systems play
a central role in computing, as standalone utilities, or as parts of other
applications.

 MySQL is based on SQL.

A relational database stores data in separate tables rather than putting all the
data in one big storeroom. This adds speed and flexibility. The SQL part of
"MySQL" stands for "Structured Query Language." SQL is the most common
standardized language used to access databases and is defined by the ANSI/ISO
SQL Standard. The SQL standard has been evolving since 1986 and several
versions exist. In this manual, "SQL-92" refers to the standard released in1992,
"SQL:1999" refers to the standard released in 1999, and"SQL:2003" refers to the
current version of the standard.

1
 MySQL software is open source.

Open Source means that it is possible for anyone to use andmodify the software.
Anybody can download the MySQL softwarefrom the Internet and use it without
paying anything. If you wish,you may study the source code and change it to suit
your needs. The MySQL software uses the GPL (GNU General Public License).

 MySQL Database Server is very fast, reliable, and easy to use.

If that is what you are looking for, you should give it a try. MySQL Server also has
a practical set of features developed in close cooperation with our users. You can
find a performance comparison of MySQL Server with other database managers
on our benchmark page. MySQL Server was originally developed to handle large
databases much faster than existing solutions and has been successfully used in
highly demanding production environments for several years. Although under
constant development, MySQL Server today offers a rich and useful set of
functions. Its connectivity, speed, and security make MySQL Server highly suited
for accessing databases on the Internet. MySQL Server works in client/server or
embedded systems. The MySQL Database Software is a client/server system that
consists of a multi-threaded SQL server that supports different backbend’s,
several different client programs and libraries, administrative tools, and a wide
range of application programming interfaces (APIS).

The main features of MySQL

 Written in C and C++.


 Works on many different platforms.
 Uses multi-layered server design with independent modules.
 Provides transactional and non-transactional storage engines.
 Designed to make it relatively easy to add other storage engines.
 This is useful if you want to provide an SQL interface for an in-house database.
 Uses a very fast thread-based memory allocation system.
 Executes very fast joins using an optimized nested-loop join.

2
 Implements SQL functions using a highly optimized class library that should be
as fast as possible. Usually there is no memory allocation at all after query
initialization.
 Provides the server as a separate program for use in a client/server networked
environment, and as a library that can be embedded (linked) into standalone
applications. Such applications can be used in isolation or in environments
where no network is available. Password security by encryption of all password
traffic when you connect to a server.
 Support for large databases. We use MySQL Server with databasesthat contain
50 million records. We also know of users who useMySQL Server with 200,000
tables and about 5,000,000,000 rows.
 MySQL client programs can be written in many languages. A clientlibrary
written in C is available for clients written in C or C++, or forany language that
provides C bindings.
 APIs for C, C++, Eiffel, Java, Perl, PHP, Python, Ruby, and Tcl areavailable,
enabling MySQL clients to be written in many languages.
 The Connector/ODBC (My ODBC) interface provides MySQL supportfor client
programs that use ODBC (Open Database Connectivity)connections.
 The Connector/J interface provides MySQL support for Java clientprograms
that use JDBC connections. Clients can be run on Windowsor Unix. Connector/J
source is available.

3
What is database?
Introduction and concepts

A database is a collection of information related to a particularsubject or purpose,


such as tracking customer orders or maintaininga music collection. Using any
RDBMS application software like MSSQL Server, MySQL, Oracle, Sybase etc, you
can manage all yourinformation from a single database file. Within the file, divide
yourdata into separate storage containers called tables. You may andretrieve the
data using queries.

A table is a collection of data about a specific topic, such as productsor suppliers.


Using a separate table for each topic means you canstore that data only once,
which makes your database more efficientand reduces data-entry errors. Table
organises data into columns(called fields) and rows (called records).

A Primary key is one or more fields whose value or values uniquelyidentify each
record in a table. In a relationship, a primary key isused to refer to specific record
in one table from another table. Aprimary key is called foreign key when it is
referred to from anothertable.

To find and retrieve just the data that meets conditions you specify,including data
from multiple tables, create a query. A query can alsoupdate or delete multiple
records at the same time, and performbuilt-in or custom calculations on your
data.

Role of DBMS application program.

A computer database works as an electronic filing system, which has alarge


number of ways of cross-referencing, and this allows the usermany different ways
in which to re-organize and retrieve data. Adatabase can handle business
inventory, accounting and filing and usethe information in its files to prepare
summaries, estimates and otherreports. The management of data in a database
system is done bymeans of a general-purpose software package called a
DatabaseManagement System (DBMS). Some commercially available DBMS
areMS SQL Server, MS ACCESS, INGRES, ORACLE, and Sybase. Adatabase

4
management system, therefore, is a combination of hardwareand software that
can be used to set up and monitor a database, andcan manage the updating and
retrieval of database that has been stored in it

Most of the database management systems havethefollowingcapabilities:

 Creating of a table, addition, deletion, modification of records.


 Retrieving data collectively or selectively.
 The data stored can be sorted or indexed at the user's discretion
anddirection.
 Variousreportscanbeproducedfromthesystem.Thesemaybeeitherstandardiz
ed report or that may be specifically generatedaccording tospecific user
definition.
 Mathematical functions can be performed and the data stored in
thedatabase can be manipulated with these functions to perform
thedesired calculations.
 To maintain data integrity and database use.

The DBMS interprets and processes users' requests to retrieveinformation from a


database. In most cases, a query request willhave to penetrate several layers of
software in the DBMS andoperating system before the physical database can be
accessed. TheDBMS responds to a query by invoking the
appropriatesubprograms, each of which performs its special function tointerpret
the query, or to locate the desired data in the database andpresent it in the
desired order.

5
UNDERSTANDING THE PYTHON MYSQL
DATABASE CONNECTION PROGRAM

import mysql.connector

✓This line imports the MySQL connector python module in the program MySQL.
Connector Error object is used to show an error when we fail to connect database
object

MySQL.connector.connect()

✓ Using this function, we can connect the MySQLdatabase;

✓ This function accepts four parameters: Host, User,Passwd, database.

✓connect(): This method is used for creating aconnection to our database it has
four arguments:

 Host Name
 Database User Name
 Database Password
 Database Name

connection.cursor()

✓ This method returns a cursor object.

✓ Using cursor object, we can execute queries.

✓ cursor(): This method creates a cursor object that iscapable for executing sql
query on database.

 execute(): This method is used for executing sql query ondatabase. It takes a
sql query (as string) as an argument.

✓close(): This method close the database connection.

6
Read operation

✓ Read operation on any database means to fetch some usefulinformation from


the database. We can use fetchone()method to fetch single record, fetchall()
method to fetchmultiple values from a database table.

✓fetchone()- It fetches the next row of a query result set.A result set is an object
that is returned when a cursor objectis used to query a table

✓fetchall() - It fetches all the rows in a result set.If some rows have already been
extracted from the result setthen it retrieves the remaining rows from the result
set

✓rowcount()- This is a read-only attribute and returns thenumber of rows that


were affected by an execute() method.

You might also like