PyZombis Modernize_MVC@c510f99
Social
Runestone in social media:
Follow @iRunestone
Our Facebook Page
Help support us:
Search
Table of Contents
Book Index
User
Assignments
Practice
Change Course
Instructor's Page
Progress Page
Edit Profile
Change Password
Register
Login
Dark Mode
Scratch Activecode
Help
FAQ
Instructors Guide
About Runestone
Report A Problem
2.
Basic concepts of SQL
¶
2.1.
Notions of databases
¶
2.2.
Creating a student database
¶
import sys sys.path.append("../../_static") ^^^^ # the following code creates a table # called students in the database students.bd from sqlite3 import connect con = connect('students.bd') cur = con.cursor() # the table has two columns: login_id and pass cur.execute('''create table students(login_id varchar(8),pass integer)''') cur.close() con.close()
2.3.
Accessing the students.bd database
¶
import sys sys.path.append("../../_static") ^^^^ from sqlite3 import connect con = connect('students.bd') cur = con.cursor() # insert values into the students table cur.execute('insert into students values("masanori",421)') cur.execute('insert into students values("emengarda",666)') # select all the contents of the students table cur.execute('select * from students') result = cur.fetchall() if(result!=None): for res in result: print("login :",res['login_id']) print("ra :",res['pass']) cur.close() con.close()
You have attempted
of
activities on this page