#Был создан python файл т.к. в условии нужна возможность подстановки параметров #задание 2 import MySQLdb #Пользовательская подстановка параметров p1 = int(input("Введите p1 ")) p2 = int(input("Введите p2 ")) p3 = int(input("Введите p3 ")) p4 = int(input("Введите p4 ")) p5 = int(input("Введите p5 ")) #Подключение к бд db = MySQLdb.connect(host="localhost", user="root", passwd="пароль", db="db", charset='utf8') cursor = db.cursor() #Сам запрос sql = """SELECT p1='%s' and p2='%o' and p3='%u' and p4='%i' and p5='%q' IF(p1=Null , 3) IF(p2=Null , 3) IF(p3=Null , 3) IF(p4=Null , 3) IF(p5=Null , 3) FROM docs """% (p1, p2, p3, p4, p5) cursor.execute(sql) db.commit() db.close()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question