Jump to content

python experts


kevinUsa

Recommended Posts

14 minutes ago, MeetFriendz said:

print(table) ('Student')

print function does not work that way ; syntax print(object) anthe anamata ; just correcting so if anyone sees this does not make that mistake

  • Like 1
Link to comment
Share on other sites

35 minutes ago, kevinUsa said:

i want ot print values from student table only 

just started to learn python 

How n where To start ba..i also want to learn python but donno where to start?

Link to comment
Share on other sites

10 minutes ago, Sarvapindi said:

How n where To start ba..i also want to learn python but donno where to start?

I am learning from udemy

 

Link to comment
Share on other sites

 

import sqlite3
conn = sqlite3.connect('aaa.sqlite')
cur = conn.cursor()
 
cur.execute('DROP TABLE IF EXISTS Student')
cur.execute('DROP TABLE IF EXISTS Courses')
 
cur.execute('CREATE TABLE Student(name TEXT, Student_id INTEGER, course_id INTEGER)')
 
cur.execute('CREATE TABLE Courses (course_id INTEGER, Course_name TEXT)')
 
cur.execute('INSERT INTO Student (name, Student_id, course_id ) VALUES (?,?,?)', ( 'TOm', '20044844', '12346' )),
cur.execute('INSERT INTO Student (name, Student_id, course_id ) VALUES (?,?,?)', ( 'TOm2', '20044842', '12345' )),
cur.execute('INSERT INTO Student (name, Student_id, course_id ) VALUES (?,?,?)', ( 'TOm4', '20044843', '12344' )),
cur.execute('INSERT INTO Student (name, Student_id, course_id ) VALUES (?,?,?)', ( 'TOm5', '200448442', '12343' ))
cur.execute('INSERT INTO Courses (course_id ,Course_name) VALUES (?,?)', ( '12345','maths' )),

cur.execute('INSERT INTO Courses (course_id ,Course_name) VALUES (?,?)', ( '12346','science' )),
cur.execute('INSERT INTO Courses (course_id ,Course_name) VALUES (?,?)', ( '12344','stats' )),
cur.execute('INSERT INTO Courses (course_id ,Course_name) VALUES (?,?)', ( '12343','eng' )),
cur.execute('INSERT INTO Courses (course_id ,Course_name) VALUES (?,?)', ( '12342','econ' ))

student_obj=cur.execute('SELECT Student.name,Student.Student_id, Courses.Course_name FROM Student JOIN Courses ON Student.course_id = Courses.course_id').fetchall()

course_obj=cur.execute('SELECT course_id, Course_name FROM Courses').fetchall()
 
print(student_obj)
print(course_obj)

Link to comment
Share on other sites

for loop rasukoni .. rows line ga print chesukovachu..

def print_func(input_obj):
    for i in input_obj:
        print(i)
    return
    
print_func(student_obj)
print_func(course_obj)

Link to comment
Share on other sites

Just now, cosmopolitan said:

for loop rasukoni .. rows line ga print chesukovachu..

def print_func(input_obj):
    for i in input_obj:
        print(i)
    return
    
print_func(student_obj)
print_func(course_obj)

got it 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...