{"id":31814053,"url":"https://github.com/le717/flask-quick-sql","last_synced_at":"2026-05-06T10:38:15.313Z","repository":{"id":150932603,"uuid":"623272197","full_name":"le717/flask-quick-sql","owner":"le717","description":"A quick way to run SQL in your Flask app.","archived":false,"fork":false,"pushed_at":"2025-12-13T15:58:37.000Z","size":158,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-15T07:42:25.166Z","etag":null,"topics":["database","flask","python","sql"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/flask-quick-sql/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/le717.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-04-04T03:23:36.000Z","updated_at":"2025-12-13T15:58:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"51253dc3-dbcb-4dc7-b947-580949f89761","html_url":"https://github.com/le717/flask-quick-sql","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/le717/flask-quick-sql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/le717%2Fflask-quick-sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/le717%2Fflask-quick-sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/le717%2Fflask-quick-sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/le717%2Fflask-quick-sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/le717","download_url":"https://codeload.github.com/le717/flask-quick-sql/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/le717%2Fflask-quick-sql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32689481,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-06T08:33:17.875Z","status":"ssl_error","status_checked_at":"2026-05-06T08:33:17.221Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["database","flask","python","sql"],"created_at":"2025-10-11T08:24:21.723Z","updated_at":"2026-05-06T10:38:15.308Z","avatar_url":"https://github.com/le717.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flask-quick-sql\n\n\u003e A quick way to run SQL in your Flask app.\n\n## Info\n\nA long time ago, I used the [`records`](https://pypi.org/project/records/) library to query a database\nwith raw SQL. It was great, [until it wasn't](https://github.com/kennethreitz/records/issues/208).\n\nFast-forward many years and I was working on replacing the code that used `records`, but I needed to keep\nthe existing code working. I also needed to remove `records` from my dependencies in order to update\nliterally _everything_, but alas, I could not.\n\nEnter this little wrapper code I wrote. It _kinda_ keeps API compat but also kinda not.\nThat wasn't my goal. My goal was to keep _enough_ compatibility so I wouldn't have to\nchange much of my code while also keeping it nice to use.\n\nThis Flask extension exists solely because I liked my wrapper code and will\nalmost certainly will have a use for it again, and I didn't want it to just go away\nwhen I deleted it from my app.\n\n## Usage\n\n* Python 3.11+\n* Flask 3.1+\n* Flask-SQLAlchemy 3.1+\n* SQLAlchemy 2.0+\n\nIf a SQLAlchemy instance already exists in your app, it will be used. Otherwise, an instance\nwill be created for you.\n\n```python\nfrom flask import Flask\nfrom flask_quick_sql import QuickSQL\n\n\ndef create_app():\n    app = Flask(__name__)\n\n    # You must set this\n    app.config[\"SQLALCHEMY_DATABASE_URI\"] = ...\n    db = QuickSQL(app)\n\n    # A very wasteful yet all too common query, especially in PHP land\n    all_users = db.query(\"SELECT * FROM users\").all()\n    print(all_users[0][\"username\"])\n    return app\n```\n\nThe immediate result of `query()` isn't very useful. You'll want to chain a call to `.all()`,\n`.first()`, or `.one()`. If there's no data, `.first()` and `.one()` will return `None`.\n\n### v1.1.0+\nYou get a `Record` instance that behaves like `records.Record`. Property, index, and key access? You\nbetcha. All methods and iteration over `query()` itself provides a `Record`.\n\n### Before v1.1.0\nYou don't get property and key access like `records` gave you. You get one or the other. By default,\nyou get a dictionary. Breaking API change from `records`? Yes. I don't care.\n\nTo get a `sqlalchemy.engine.Row` (basically `collections.namedtuple`) object instead,\npass `as_nt=True` as a parameter to any method.\n\nYou can also iterate over the whole result set, with each dictionary record being `yield`ed\n(you cannot get a named tuple when doing this):\n\n```python\n[User(**r) for r in quick_sql.query(\"SELECT * FROM users\")]\n```\n\n### Both lifetimes\nBecause SQLAlchemy is used under the hood, prepared statements work as expected:\n\n```python\nsql = \"SELECT * FROM users WHERE is_active = :is_active\"\n[User(**r) for r in db.query(sql, is_active=False)]\n```\n\nHave fun running your [SQuirreL](http://www.squirrelsql.org/) queries.\n\n## License\n\n[Public domain](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fle717%2Fflask-quick-sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fle717%2Fflask-quick-sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fle717%2Fflask-quick-sql/lists"}