SHARE
TWEET

ahoj mílo

a guest Feb 14th, 2020 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import mysql.connector
  2.  
  3. def vypis_zaky(mydb, razeni):
  4.     mycursor = mydb.cursor()
  5.     mycursor.execute("SELECT * FROM zaci ORDER BY " + razeni +";")
  6.     myresult = mycursor.fetchall()
  7.  
  8.     for x in myresult:
  9.         print(x[1], x[2])
  10.  
  11. def prihlas(uzivatel, heslo):
  12.   global mydb
  13.   mycursor = mydb.cursor()
  14.   mycursor.execute("SELECT id FROM zaci WHERE jmeno ='%s' and heslo = '%s';"
  15.                    % (uzivatel, heslo))
  16.   myresult = mycursor.fetchone()
  17.   if myresult is not None:
  18.     print("ok")
  19.   else:
  20.     print("chyba")
  21. try:
  22.     mydb = mysql.connector.connect(
  23.         host = "studenti.odbornaskola.cz",
  24.         user = "u319",
  25.         password = "22a44e",
  26.         database = "u319",
  27.         port = "3306"
  28.  
  29.     )
  30. except mysql.connector.Error:
  31.     print("Připojení se nepodařilo")
  32.  
  33. vypis_zaky(mydb,"jmeno")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top