{"id":14974104,"url":"https://github.com/mikeshultz/rawl","last_synced_at":"2026-02-28T21:33:06.346Z","repository":{"id":55431612,"uuid":"110199696","full_name":"mikeshultz/rawl","owner":"mikeshultz","description":"This module is a simple database abstraction trying to balance the usefulness of an ORM with the lack of constraints and flexibility of rawl SQL.","archived":false,"fork":false,"pushed_at":"2023-09-27T00:31:06.000Z","size":112,"stargazers_count":0,"open_issues_count":7,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-29T10:14:10.532Z","etag":null,"topics":["database","postgresql","psycopg2","python3","sql"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mikeshultz.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}},"created_at":"2017-11-10T03:48:24.000Z","updated_at":"2020-12-31T07:06:06.000Z","dependencies_parsed_at":"2022-08-15T00:10:33.256Z","dependency_job_id":null,"html_url":"https://github.com/mikeshultz/rawl","commit_stats":{"total_commits":113,"total_committers":1,"mean_commits":113.0,"dds":0.0,"last_synced_commit":"49c878f9864845e5a123259aa115a5acc0aab7c2"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/mikeshultz/rawl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeshultz%2Frawl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeshultz%2Frawl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeshultz%2Frawl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeshultz%2Frawl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikeshultz","download_url":"https://codeload.github.com/mikeshultz/rawl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeshultz%2Frawl/sbom","scorecard":{"id":645972,"data":{"date":"2025-08-11","repo":{"name":"github.com/mikeshultz/rawl","commit":"49c878f9864845e5a123259aa115a5acc0aab7c2"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/27 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/coverage.yaml:1","Warn: no topLevel permission defined: .github/workflows/lint.yaml:1","Warn: no topLevel permission defined: .github/workflows/pytest.yaml:1","Warn: no topLevel permission defined: .github/workflows/release.yaml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/coverage.yaml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/mikeshultz/rawl/coverage.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/coverage.yaml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/mikeshultz/rawl/coverage.yaml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/coverage.yaml:60: update your workflow using https://app.stepsecurity.io/secureworkflow/mikeshultz/rawl/coverage.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yaml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/mikeshultz/rawl/lint.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yaml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/mikeshultz/rawl/lint.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pytest.yaml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/mikeshultz/rawl/pytest.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yaml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/mikeshultz/rawl/release.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yaml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/mikeshultz/rawl/release.yaml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yaml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/mikeshultz/rawl/release.yaml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yaml:60: update your workflow using https://app.stepsecurity.io/secureworkflow/mikeshultz/rawl/release.yaml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/coverage.yaml:38","Warn: pipCommand not pinned by hash: .github/workflows/coverage.yaml:39","Warn: pipCommand not pinned by hash: .github/workflows/coverage.yaml:41","Warn: pipCommand not pinned by hash: .github/workflows/coverage.yaml:43","Warn: pipCommand not pinned by hash: .github/workflows/lint.yaml:21","Warn: pipCommand not pinned by hash: .github/workflows/lint.yaml:22","Warn: pipCommand not pinned by hash: .github/workflows/lint.yaml:24","Warn: pipCommand not pinned by hash: .github/workflows/lint.yaml:26","Warn: pipCommand not pinned by hash: .github/workflows/pytest.yaml:28","Warn: pipCommand not pinned by hash: .github/workflows/pytest.yaml:29","Warn: pipCommand not pinned by hash: .github/workflows/pytest.yaml:31","Warn: pipCommand not pinned by hash: .github/workflows/pytest.yaml:33","Warn: pipCommand not pinned by hash: .github/workflows/release.yaml:21","Warn: pipCommand not pinned by hash: .github/workflows/release.yaml:22","Warn: pipCommand not pinned by hash: .github/workflows/release.yaml:23","Warn: pipCommand not pinned by hash: .github/workflows/release.yaml:27","Info:   0 out of   7 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 third-party GitHubAction dependencies pinned","Info:   0 out of  16 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: GNU General Public License v3.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":9,"reason":"1 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2024-48 / GHSA-fj7x-q9j7-g6q6"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 4 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T12:09:10.229Z","repository_id":55431612,"created_at":"2025-08-21T12:09:10.229Z","updated_at":"2025-08-21T12:09:10.229Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29952294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T18:42:55.706Z","status":"ssl_error","status_checked_at":"2026-02-28T18:42:48.811Z","response_time":90,"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","postgresql","psycopg2","python3","sql"],"created_at":"2024-09-24T13:49:57.656Z","updated_at":"2026-02-28T21:33:06.328Z","avatar_url":"https://github.com/mikeshultz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rawl\n[![Lint](https://github.com/mikeshultz/rawl/workflows/lint/badge.svg)](https://github.com/mikeshultz/rawl/actions?query=workflow%3Alint)\n[![Test](https://github.com/mikeshultz/rawl/workflows/test/badge.svg)](https://github.com/mikeshultz/rawl/actions?query=workflow%3Atest)\n[![Release](https://github.com/mikeshultz/rawl/workflows/release/badge.svg)](https://github.com/mikeshultz/rawl/actions?query=workflow%3Arelease)\n[![codecov](https://codecov.io/gh/mikeshultz/rawl/branch/master/graph/badge.svg?token=15WQT4DXKP)](https://codecov.io/gh/mikeshultz/rawl)\n\nAn odd raw sql abstraction library.  It might suck.\n\n**NOTE**: This is not an ORM, nor intended to hide the database.  It's more or \nless a wrapper around [psycopg2](http://initd.org/psycopg/docs/).  It __will \nnot__ create the database for you, either.  Nor should it!  __Proper database \ndesign can not be abstracted away.__  That said, with some care you can execute \na set of queries to create your schema if needed.  See the tests for an \nexample.\n\n## Usage\n\n### Simple Connection\n\nThe most rudimentary way to use Rawl is with `RawlConnection`.  It's basically \njust a wrapper for [psycopg2's connection](http://initd.org/psycopg/docs/connection.html).\n\n    with RawlConnection(\"postgresql://myUser:myPass@db.example.com/my_database\") as connection:\n        cursor = connection.cursor()\n        cursor.execute(\"SELECT * from my_table;\")\n        results = cursor.fetchall()\n\nThis isn't really the useful part of Rawl, so perhaps you'd rather build data\ncontrollers or models.\n\n### Models\n\nCreate model classes that derrive from `RawlBase`.  `RawlBase` provides some \nuseful methods: \n \n - `query` - Executes a query from provided SQL string template and parameters\n - `select` - Executes a query from provided SQL string template, columns, and \n    parameters\n - `process_columns` - Converts an iterable to a list of strings that represent\n    column names.\n\nThese are also available, though not especially inteded to be used by the user \nunless necessary.\n - `_assemble_select` - Put together a compiled Psycopg2 SQL SELECT from an SQL\n    string template and query parameters.\n - `_assemble_simple` - Put together a compiled Psycopg2 SQL statement from an \n    SQL string template and query parameters.\n - `_execute` - Executes an assembled SQL query\n\nHere's a very simple example of a model:\n\n    from rawl import RawlBase\n    \n    DSN = \"postgresql://myUser:myPass@myserver.example.com/my_db\"\n\n\n    class StateModel(RawlBase):\n        def __init__(self):\n            # Init the parent\n            super(StateModel, self).__init__(DSN, table_name='state', \n                columns=['state_id', 'name'])\n\n        def get_name(self, pk):\n            \"\"\" My special method returning only a name for a state \"\"\"\n            \n            result = self.select(\"SELECT {0} FROM state WHERE state_id = %s;\", \n                ['name'], pk)\n            \n            # Return first row column 'name'\n            return result[0].name\n\n    if __name__ == \"__main__\":\n        for state in StateModel().all(): \n            print(state.name)\n\nAnd of course you can add your own methods for various specialty queries or \nanything you want.\n\n### Results\n\nUnless otherwise altered by the implemented methods, results returned from any \nquery are always a list of `RawlResult` objects.  You can treat these as if \nthey were `dict`s, `object`s, or `list`s.  For instance:\n\n    for row in StateModel().all():\n        \n        # These are all the same\n        print(row.state_id)\n        print(row['state_id'])\n        print(row[0])\n\n        # Or iterate through the columns\n        for col in row:\n            print(col)\n\n`RawResult` should be suitable for serialization(pickling), but should you need \nto convert to a python type, use `RawResult.to_dict()` or `RawResult.to_list()`.\n\n### Transactions\n\nThere's some rudimentary support for transactions within models as well.  You\ncan start a transaction by calling `start_transaction()` on the model and\nfinalize the transaction either by calling `rollback()` or `commit()`.\n\n    model = StateModel(DSN)\n    model.start_transaction()\n    model.insert_dict({\"state_id\": \"PA\", \"name\": \"Pennsylvania\"})\n    model.commit()\n\n### JSON Encoding\n\nIn case you want to convert your query results directly to a JSON string for \noutput, you can use RawlJSONEncoder.\n\n    json.dumps(StateModel().all(), cls=RawlJSONEncoder)\n\n## Testing\n\nInstall the dependencies.\n\n    pip install -r requirements.dev.txt\n\nRun pytest with the following environmental variables.\n\n - `PG_DSN` - Database connection string for a non-test database.  If a single instance install, database `postgres` will do.\n - `RAWL_DSN` - Connection string for the test database.  **It will be dropped and recreated.**\n\nThe `-v` switch is for logging verbosity.  Add more `v`'s for a lower log level.  For example:\n\n    PG_DSN=\"postgresql://myUser:myPassword@db.example.com:5432/postgres\" RAWL_DSN=\"postgresql://myUser:myPassword@db.example.com:5432/rawl_test\" pytest -s -vvvv\n\n## Release\n\nThis should take care of doing a release(including a PyPi release)\n\n - Bump version in `setup.py` and commit\n - Tag version(e.g. `git tag v0.1.0b1`)\n - Push to `origin`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikeshultz%2Frawl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikeshultz%2Frawl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikeshultz%2Frawl/lists"}