{"id":15067200,"url":"https://github.com/alexferl/flask-mysqldb","last_synced_at":"2025-05-15T18:07:05.489Z","repository":{"id":27340494,"uuid":"30815364","full_name":"alexferl/flask-mysqldb","owner":"alexferl","description":"MySQL extension for the Flask web framework","archived":false,"fork":false,"pushed_at":"2025-01-13T18:25:01.000Z","size":112,"stargazers_count":123,"open_issues_count":4,"forks_count":58,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-07T23:11:18.901Z","etag":null,"topics":["flask","flask-extension","flask-mysqldb","mysqldb"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexferl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-15T02:16:52.000Z","updated_at":"2024-12-27T14:12:05.000Z","dependencies_parsed_at":"2023-10-05T05:17:31.786Z","dependency_job_id":"27c3c144-26ae-4e3e-b4e5-f0a25474f5a1","html_url":"https://github.com/alexferl/flask-mysqldb","commit_stats":{"total_commits":53,"total_committers":7,"mean_commits":7.571428571428571,"dds":0.5849056603773585,"last_synced_commit":"1e0225dfad3f7c0e174f7f16282774eea9cca6d4"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexferl%2Fflask-mysqldb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexferl%2Fflask-mysqldb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexferl%2Fflask-mysqldb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexferl%2Fflask-mysqldb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexferl","download_url":"https://codeload.github.com/alexferl/flask-mysqldb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254394720,"owners_count":22063984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","flask-extension","flask-mysqldb","mysqldb"],"created_at":"2024-09-25T01:18:08.339Z","updated_at":"2025-05-15T18:07:05.433Z","avatar_url":"https://github.com/alexferl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flask-MySQLdb\nFlask-MySQLdb provides MySQL connection for Flask.\n\n## Quickstart\nFirst, you _may_ need to install some dependencies for [mysqlclient](https://github.com/PyMySQL/mysqlclient)\nif you don't already have them, see [here](https://github.com/PyMySQL/mysqlclient#install).\n\nSecond, install Flask-MySQLdb:\n```shell\npip install flask-mysqldb\n```\n\nFlask-MySQLdb depends, and will install for you, recent versions of Flask\n(2.2.5 or later) and [mysqlclient](https://github.com/PyMySQL/mysqlclient).\nFlask-MySQLdb is compatible with and tested with Python 3.8+.\n\nNext, add a `MySQL` instance to your code:\n\n```python\nfrom flask import Flask\nfrom flask_mysqldb import MySQL\n\napp = Flask(__name__)\n\n# Required\napp.config[\"MYSQL_USER\"] = \"user\"\napp.config[\"MYSQL_PASSWORD\"] = \"password\"\napp.config[\"MYSQL_DB\"] = \"database\"\n# Extra configs, optional:\napp.config[\"MYSQL_CURSORCLASS\"] = \"DictCursor\"\napp.config[\"MYSQL_CUSTOM_OPTIONS\"] = {\"ssl\": {\"ca\": \"/path/to/ca-file\"}}  # https://mysqlclient.readthedocs.io/user_guide.html#functions-and-attributes\n\nmysql = MySQL(app)\n\n@app.route(\"/\")\ndef users():\n    cur = mysql.connection.cursor()\n    cur.execute(\"\"\"SELECT user, host FROM mysql.user\"\"\")\n    rv = cur.fetchall()\n    return str(rv)\n\nif __name__ == \"__main__\":\n    app.run(debug=True)\n```\n\nOther configuration directives can be found [here](https://github.com/alexferl/flask-mysqldb/blob/master/flask_mysqldb/__init__.py#L31).\n\n## Why\nWhy would you want to use this extension versus just using MySQLdb by itself?\nThe only reason is that the extension was made using Flask's best practices in relation\nto resources that need caching on the [app context](https://flask.palletsprojects.com/en/2.0.x/appcontext/).\nWhat that means is that the extension will manage creating and teardown the connection to MySQL\nfor you while with if you were just using MySQLdb you would have to do it yourself.\n\n\n## Resources\n- [PyPI](https://pypi.org/project/Flask-MySQLdb/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexferl%2Fflask-mysqldb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexferl%2Fflask-mysqldb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexferl%2Fflask-mysqldb/lists"}