1. Python / Говнокод #24694

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    import datetime
    import mysql.connector
    
    cnx = mysql.connector.connect(user='scott', database='employees')
    cursor = cnx.cursor()
    
    query = ("SELECT first_name, last_name, hire_date FROM employees "
             "WHERE hire_date BETWEEN %s AND %s")
    
    hire_start = datetime.date(1999, 1, 1)
    hire_end = datetime.date(1999, 12, 31)
    
    cursor.execute(query, (hire_start, hire_end))
    
    for (first_name, last_name, hire_date) in cursor:
      print("{}, {} was hired on {:%d %b %Y}".format(
        last_name, first_name, hire_date))
    
    cursor.close()
    cnx.close()

    Как выглядит mysql_real_escape_string в Python?

    Запостил: real_escape_string, 31 Августа 2018

    Комментарии (1) RSS

    Добавить комментарий