Connect to MySQL database

    -1

    47

    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
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.