Skip to main content

Posts

mysql connectivity python

import mysql.connector import datetime mydb=mysql.connector.connect(host="localhost",\                              user="root",\                              passwd="root",\                              database="practicalexam") mycursor=mydb.cursor() def teacheradd():     L=[]     tno=int(input("Enter tno:"))     L.append(tno)     tname=input("Enter tname:")     L.append(tname)     tsalary=int(input("Enter tsalary:"))     L.append(tsalary)     value=L     value=(tno,tname,tsalary)     sql="insert into teacher(tno,tname,tsalary)values(%s,%s,%s)"     mycursor.execute(sql,value)     mydb.commit() def teachersearch():   ...

Data Management {CLASS XI}

Q: What is a Database? The collection of data is usually referred to as the DATABASE. The database maintains the information that help to the decision-making process in an organization. The same data in a database may serve many application. e.g.: A database of employees of an organization, Database of students of a school, etc. Database System It is basically a computer based record keeping system. The Relational Data Model In Relational data model, the data is organized into tables ( i.e. rows & cols). These tables are called relations. A row in a table represents a relationship among a set of values. Terminology in RDBMS The different terms used in the relational model are: 1.Relation 2.Tuples 3.Attributes 4.Degree 5.Cardinality 6.Domain 1. Relation A Relation is a table (i.e rows & cols) In above example (STUDENT) is a relation that has 4 rows (records) and 3 columns (fields). 2. Tuples The rows of a relation are gener...

TUPLES

The Python tuples are sequences that are used to store a tuple of values of any type. • Tuples are immutable. • Tuple is a type of sequence like string and list but it differs from them in way that lists are mutable but strings and tuples are immutable Creating and Accessing Tuples Tuples are depicted through parenthesis. () Empty tuple (1,2,3) Tuple of integers (2,3.5,6,7.5) Tuple of integer and float (‘ x’,’y’,’z ’) Tuples of characters Creating Tuples 1. Empty Tuple >>> t=tuple() >>> t () 2. Single Element >>> t=(1) >>> t 1 >>> t=3 , # to construct a tuple with one element just add comma >>> t (3,) 3. Long Tuples >>> t1=(11,22,33,44,55,66,77,88) >>> t1 (11, 22, 33, 44, 55, 66, 77, 88) >>> print (t1) (11, 22, 33, 44, 55, 66, 77, 88) 4. Nested Tuples : t=(11,22,(33,44),55) >>> t (11, 22, (33, 44), 55) Creating Tuple...
LIST (Class XI) • It is an ordered set of values enclosed in square brackets []. • Values in the list can be modified, i.e. it is mutable. • As it is set of values, we can use index in square brackets [] to identify a value belonging to it. • The values that make up a list are called its elements, and they can be of any type. . Its syntax is: Variable name [index] (variable name is name of the list). Let's look at some example of simple list: i) >>>L1 = [1, 2, 3, 4] # list of 4 integer elements. ii) >>>L2 = [“Delhi”, “Chennai”, “Mumbai”] #list of 3 string elements. iii) >>>L3 = [ ] # empty list i.e. list with no element iv) >>>L4 = [“ abc ”, 10, 20] # list with different types of elements v) >>>L5 = [1, 2, [6, 7, 8], 3] # A list containing another list known as nested list Creating and Accessing List • To create a list, put a number of expressions in square brackets. L=[] L=[value1, ...