Data manipulation through

Unit 15 > Computer Science > Class 12 > Samacheer Kalvi - English Medium

Objectives


• Create a table and to add new rows in the database. • Update and Delete record in a table • Query the table • Write the Query in a CSV fi le

Summary


• A database is an organized collection of data. • Users of database can be human users, other programs or applications • SQLite is a simple relational database system, which saves its data in regular data files. • Cursor is a control structure used to traverse and fetch the records of the database. All the SQL commands will be executed using cursor object only. • As data in a table might contain single or double quotes, SQL commands in Python are denoted as triple quoted string. • “Select” is the most commonly used statement in SQL • The SELECT Statement in SQL is used to retrieve or fetch data from a table in a database • The GROUP BY clause groups records into summary rows • The ORDER BY Clause can be used along with the SELECT statement to sort the data of specific fields in an ordered way • Having clause is used to filter data based on the group functions. • Where clause cannot be used along with ‘Group by’ • The WHERE clause can be combined with AND, OR, and NOT operators • The ‘AND’ and ‘OR’ operators are used to filter records based on more than one condition • Aggregate functions are used to do operations from the values of the column and a single value is returned. • COUNT() function returns the number of rows in a table. • AVG() function retrieves the average of a selected column of rows in a table. • SUM() function retrieves the sum of a selected column of rows in a table. • MAX() function returns the largest value of the selected column. • MIN() function returns the smallest value of the selected column • sqlite_master is the master table which holds the key information about your database tables. • The path of a file can be either represented as ‘/’ or using ‘\’ in Python. For example the path can be specified either as 'c:/pyprg/sql.csv', or c:\pyprg\sql.csv’.