-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
393 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
print('What is your age?') # ask for their age | ||
myAge = input() | ||
print('You will be ' + str(int(myAge) + 1) + ' in a year.') | ||
print('You will be ' + myAge *2 + ' in a year.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import MySQLdb | ||
db = MySQLdb.connect('localhost', 'root', '', 'davschool') | ||
cursor = db.cursor() | ||
cursor.execute('select * from games;') | ||
rows = cursor.rowcount | ||
db.close() | ||
print('Total number of records :',rows) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,2 @@ | ||
# ------------------------------------------------------------------------------- | ||
# Name: module1 | ||
# Purpose: | ||
# | ||
# Author: acer | ||
# | ||
# Created: 12-04-2018 | ||
# Copyright: (c) acer 2018 | ||
# Licence: <your licence> | ||
# ------------------------------------------------------------------------------- | ||
|
||
import MySQLdb | ||
from prettytable import PrettyTable | ||
# Open database connection | ||
db = MySQLdb.connect("localhost", "root", "", "binarynote") | ||
cursor = db.cursor() | ||
sql = "select * from question" | ||
cursor.execute(sql) | ||
results = cursor.fetchall() | ||
t = PrettyTable(['ID', 'Question', 'A', 'B', 'C', 'D', | ||
'Ans', 'Exp', 'gid', 'sid', 'tid']) | ||
for idr, question, a, b, c, d, ans, exp, gid, sid, tid in results: | ||
#idr = record[0] | ||
#name = record[1] | ||
#fname = record[2] | ||
#add = record[3] | ||
t.add_row([idr, question, a, b, c, d, ans, exp, gid, sid, tid]) | ||
# print(idr,name,fname,add,phone,email) | ||
print(t) | ||
db.close() | ||
import mysql.connector | ||
conn = mysql.connector.connect(host='localhost',database='davschool',user='root',password='') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import mysql.connector | ||
conn = mysql.connector.connect(host='localhost',database='davschool',user='root',password='') | ||
cursor = conn.cursor() | ||
cursor.execute('insert into games values(4,"fun with python",1500)') | ||
conn.close() | ||
print('Record inserted successfully') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.