{"id":20238497,"url":"https://github.com/marcinn/sqltemplate","last_synced_at":"2026-03-15T21:11:36.106Z","repository":{"id":57470633,"uuid":"81549749","full_name":"marcinn/sqltemplate","owner":"marcinn","description":"SQL templating library","archived":false,"fork":false,"pushed_at":"2023-04-21T20:25:35.000Z","size":15,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T10:10:02.514Z","etag":null,"topics":["library","python","python3","sql","template"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcinn.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":"2017-02-10T09:34:25.000Z","updated_at":"2021-04-26T04:03:26.000Z","dependencies_parsed_at":"2024-11-14T08:44:52.154Z","dependency_job_id":null,"html_url":"https://github.com/marcinn/sqltemplate","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"e083f5262ae4439843210e32843b9b644604fdf1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcinn%2Fsqltemplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcinn%2Fsqltemplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcinn%2Fsqltemplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcinn%2Fsqltemplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcinn","download_url":"https://codeload.github.com/marcinn/sqltemplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248281423,"owners_count":21077423,"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":["library","python","python3","sql","template"],"created_at":"2024-11-14T08:34:29.837Z","updated_at":"2026-03-15T21:11:31.066Z","avatar_url":"https://github.com/marcinn.png","language":"Python","readme":"# sqltemplate\nDatabase query tool based on SQL templates\n\n## Development status\n\n* Alpha\n* API may be radically changed until first Beta release\n* Not tested automatically yet\n \n### Roadmap\n\n* 0.6 - drop django-sqltemplate compatibility layer\n* 0.7 - automated tests, first beta release\n* 0.8 - stable API\n* 0.9,\u003c1.0 - minor improvements without API changes, bugfixes\n* 1.0 - first stable release\n\n## Introduction\n\nSQL is a great and poweruful DSL, which is easeier in maintenance \nwhen you're working on complext queries (i.e. reporting queries).\nBut the main problem of raw SQL is a commonly used \"spaghetti\" anti-pattern, \nwhen you're embedding/building SQLs directly in your code.\n\nThe solution comes from templating SQLs idea and `sqltemplate` \nis a simple implementation of it.\n\n## Template system / database agnostic\n\nThe `sqltemplate` provides an abstraction layer for templating SQL\nqueries and working with query results. It requires an adapter to work.\n\nFor example - if you want to use `sqltemplate` together with Django\ntemplates and database management, use [django-sqltemplate](https://github.com/marcinn/django-sqltemplate) adapter\ndirectly.\n\n\n## Backward compatibilty with `django-template`\n\nThe 0.5.x branch contains a compatibility layer with `django-template`.\nThe layer provides Django adapter and necessary imports.\n\n\n## Building an adapter\n\n\nAdapter must implement few callables required by `sqltemplate` core.\nThe adapter may be as a class instance or pure Python module providing\nsuch functions. These functions are defined as:\n\n`load_template(template_name)`\n\nMust load template by name and return some kind of template object,\nwhich will be passed to `render_template()` as an argument.\n\n\n`create_template_from_string(string)`\n\nCreates template object from provided string.\n\n\n`render_template(template, context)`\n\nMust render the template object using provided context (a dict).\n\n\n`do_query(sql, query_params, using=None)`\n\nMust execute a `sql` query with `query_params` applied.\n\nOptional `using` argument specifies database connection identifier.\nThis may be any object dependent on how your adapter recognizes \nparticular connections. For Django adapter, for example, this is a \nstring with a connection name.\n\n\n## Dependencies\n\n* sqlparse\n* flatdict\n\n## License\n\nBSD\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcinn%2Fsqltemplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcinn%2Fsqltemplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcinn%2Fsqltemplate/lists"}