{"id":18829442,"url":"https://github.com/adeadfed/postgresql-filenode-editor","last_synced_at":"2025-10-09T04:34:07.183Z","repository":{"id":220833762,"uuid":"737901738","full_name":"adeadfed/postgresql-filenode-editor","owner":"adeadfed","description":"Python 3 tool to view and edit PostgreSQL filenodes","archived":false,"fork":false,"pushed_at":"2024-02-06T22:59:07.000Z","size":3342,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-04T04:12:41.535Z","etag":null,"topics":["postgresql","python3"],"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/adeadfed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-01T22:43:49.000Z","updated_at":"2024-09-17T17:57:47.000Z","dependencies_parsed_at":"2024-02-06T23:51:35.041Z","dependency_job_id":null,"html_url":"https://github.com/adeadfed/postgresql-filenode-editor","commit_stats":null,"previous_names":["adeadfed/postgresql-filenode-editor"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adeadfed/postgresql-filenode-editor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adeadfed%2Fpostgresql-filenode-editor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adeadfed%2Fpostgresql-filenode-editor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adeadfed%2Fpostgresql-filenode-editor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adeadfed%2Fpostgresql-filenode-editor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adeadfed","download_url":"https://codeload.github.com/adeadfed/postgresql-filenode-editor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adeadfed%2Fpostgresql-filenode-editor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000702,"owners_count":26082921,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["postgresql","python3"],"created_at":"2024-11-08T01:44:50.090Z","updated_at":"2025-10-09T04:34:07.141Z","avatar_url":"https://github.com/adeadfed.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PostgreSQL Filenode Editor\nPostgreSQL Filenode Editor allows you to directly read and update data within PostgreSQL filenodes, the on-disk storage structure of PostgreSQL databases. \n\nBoth raw and datatype-based parsing modes supported. However,the tool requires additional information, stored in a separate PostgreSQL table, to properly reinterpret row data to use the latter one.\n\nThe format of filenodes is described in great detail on [the following PostgreSQL documentation page](https://www.postgresql.org/docs/current/storage-file-layout.html).\n\nOnly regular (non-TOAST) tables are supported at this point.\n\n## Setup\n```\ngit clone https://github.com/adeadfed/postgresql-filenode-editor\ncd postgresql-filenode-editor\npython3 -m pip install -r requirements.txt\n```\n\n## Usage\n### Obtaining filenode for a table\nFilenodes are named with a PostgreSQL class ID of the related table. To obtain the filenode location and name of the target table, you can run the following SQL queries:\n```sql\n-- obtain PostgreSQL root data directory\nSELECT setting FROM pg_settings WHERE name = 'data_directory';\n-- obtain path to the target filenode, relative to the data directory\nSELECT pg_relation_filepath('TABLE_NAME');\n```\n\n### Datatype-based parsing\nTo enable datatype-based parsing, you will need to extract type information, associated with the table, stored in the filenode, and supply it to the tool in a CSV format. \n\nYou can use this query to get a correct CSV-formatted data:\n```sql\nSELECT\n    STRING_AGG(\n        CONCAT_WS(\n            ',',\n            attname,\n            typname,\n            attlen,\n            attalign\n        ),\n        ';'\n    )\nFROM pg_attribute\n    JOIN pg_type\n        ON pg_attribute.atttypid = pg_type.oid\n    JOIN pg_class\n        ON pg_attribute.attrelid = pg_class.oid\nWHERE pg_class.relname = 'TABLE_NAME';\n```\n\nAll commands will now properly parse and present data in a human-readable format.\n\n![Datatype mode](demo/demo_datatype.gif)\n\n### Raw parsing\nWithout a proper datatype provided, the tool will only display raw data bytes. Editing in this mode is not does not guarantee stable results due to the missing information about NULL fields and their types.\n\nResulting filenodes may not be properly reinterpreted by the PostgreSQL servers.\n![Raw mode](demo/demo_raw.gif)\n\n#### Listing all items and pages\n```bash\npython3 postgresql_filenode_editor.py --filenode-path \u003cPATH_TO_FILENODE\u003e --mode list [--datatype-csv \u003cOPTIONAL_DATATYPE_CSV\u003e]\n```\n\n#### Listing all items in one page\n```bash\npython3 postgresql_filenode_editor.py --filenode-path \u003cPATH_TO_FILENODE\u003e --mode list --page 0 [--datatype-csv \u003cOPTIONAL_DATATYPE_CSV\u003e]\n```\n\n#### Reading single item\n```bash\npython3 postgresql_filenode_editor.py --filenode-path \u003cPATH_TO_FILENODE\u003e --mode read --page 0 --item 0 [--datatype-csv \u003cOPTIONAL_DATATYPE_CSV\u003e]\n```\n\n#### Updating single item (datatype)\n```bash\npython3 postgresql_filenode_editor.py --datatype-csv \u003cDATATYPE_CSV\u003e --filenode-path \u003cPATH_TO_FILENODE\u003e --mode update --page 0 --item 0 --csv-data \u003cNEW_ITEM_DATA_CSV\u003e\n```\n\n#### Updating single item (raw)\n```bash\npython3 postgresql_filenode_editor.py --filenode-path \u003cPATH_TO_FILENODE\u003e --mode raw_update --page 0 --item 0 --b64-data \u003cNEW_ITEM_DATA_B64\u003e\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadeadfed%2Fpostgresql-filenode-editor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadeadfed%2Fpostgresql-filenode-editor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadeadfed%2Fpostgresql-filenode-editor/lists"}