Interface Python With SQL Database
Interface Python With SQL Database
Informatics
Practices
Class XII ( As per Interface python
CBSE Board) with SQL
Database And
SQL commands
New
Syllabus
2019-20
Form/any user interface designed in any programming language is Front End where as data given
by database as response is known as Back-End database.
SQL is just a query language, it is not a database. To perform SQL queries, we need to install any
database for example Oracle, MySQL, MongoDB, PostGres SQL, SQL Server, DB2 etc.
Using SQL in any of the dbms ,databases and table can be created and data can be accessed,
updated and maintained. The Python standard for database interfaces is the Python DB-API. Python
Database API supports a wide range of database servers, like msql , mysql, postgressql, Informix,
oracle, Sybase etc.
Above program will add a column marks in the table student and will display
the structure of the table
Above statements will prompt a name from user,as user type the name ,that
name is searched into the table student with the help of select query .result
will be shown with the help of mycursor collection.
MySQLCursor.fetchall() Method
The method fetches all (or all remaining) rows of a query result set and returns a
list of tuples. If no more rows are available, it returns an empty list.
MySQLCursor.fetchone() Method
This method retrieves the next row of a query result set and returns a single
sequence, or None if no more rows are available. By default, the returned tuple
consists of data returned by the MySQL server, converted to Python objects.
MySQLCursor.fetchmany() Method
rows = cursor.fetchmany(size=1)
This method fetches the next set of rows of a query result and returns a list
of tuples. If no more rows are available, it returns an empty list.
Name Purpose
SUM() Returns the sum of given column.
MIN() Returns the minimum value in the given column.
MAX() Returns the maximum value in the given column.
AVG() Returns the Average value of the given column.
COUNT() Returns the total number of values/ records as per given
column.
Note :- Where clause works in respect of whole table but Having works
on Group only. If Where and Having both are used then Where will be
executed first.