Connect to MySQL database

    -1

    37

    mysqldatabase
    Python public recipes

    Connect to a MySQL database. use_pure uses te Python and not the pure C interface

    import mysql.connector
    
    mysql.connector.connect(host=hostname,
                            user=username,
                            passwd=password,
                            database=databasename,
                            charset='utf8mb4',
                            use_pure=True,
                            connection_timeout=10)
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.