📖 generic · 12th TN - English Medium · COMPUTER SCIENCE · Page 284question

DATA MANIPULATION THROUGH SQL

Chapter 4: 6 · COMPUTER SCIENCE

DATA MANIPULATION THROUGH SQL 12th Computer Chapter - - Data Manipulation Through SQL • Cursor in step : is a control structure used to traverse and fetch the records of the database. • Cursor has a major role in working with Python. All the commands will be executed using cursor object only. To create a table in the database, create an object and write the SQL command in it.

Example:- = "SQL statement" For executing the command use the cursor method and pass the required sql command as a parameter. Many number of commands can be stored in the and can be executed one after other. Any changes made in the values of the record should be saved by the commend "Commit" before closing the "Table connection". Creating a Database using SQLite .

The following example explains how a connection to be made to a database through Python sqlite3 # Python code to demonstrate table creation and insertions with SQL # importing module import sqlite3 # connecting to the database connection = sqlite3.connect ("Academy.db") # cursor cursor = connection.cursor() In the above example a database with the name "Academy" would be created. It's similar to the sql command "CREATE DATABASE Academy;" to SQL server."sqlite3.connect ('Academy.db')" is again used in some program, "connect" command just opens the already created database. . .

Creating a Table After having created an empty database, you will most probably add one or more tables to this database. The SQL syntax for creating a table "Student" in the database "Academy" looks like as follows : CREATE TABLE Student ( Rollno INTEGER, Sname VARCHAR( ), Grade CHAR( ), gender CHAR( ), Average float( , ), DATE, PRIMARY KEY (Rollno) ); This is the way, somebody might do it on a SQL command shell. Of course, we want to do this directly from Python. To be capable to send a command to "SQL", or SQLite, we need a 12th Computer Chapter - - cursor object.

Usually, a cursor in SQL and databases is a control structure to traverse over the records in

Related topics

Have a question about this topic?

Get an AI answer grounded in your actual textbook — with the exact page reference.

Ask AI about this topic →