{"id":21228507,"url":"https://github.com/david1602/pg-to-excel","last_synced_at":"2026-05-20T02:49:20.817Z","repository":{"id":57322653,"uuid":"103293030","full_name":"david1602/pg-to-excel","owner":"david1602","description":"Generates an excel file from a postgresql connection and a query (file)","archived":false,"fork":false,"pushed_at":"2022-06-10T12:23:31.000Z","size":27,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-21T09:05:19.829Z","etag":null,"topics":["excel","postgres","postgresql","xlsx"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/david1602.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}},"created_at":"2017-09-12T16:08:53.000Z","updated_at":"2022-12-07T12:08:04.000Z","dependencies_parsed_at":"2022-08-26T01:11:28.168Z","dependency_job_id":null,"html_url":"https://github.com/david1602/pg-to-excel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/david1602%2Fpg-to-excel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/david1602%2Fpg-to-excel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/david1602%2Fpg-to-excel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/david1602%2Fpg-to-excel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/david1602","download_url":"https://codeload.github.com/david1602/pg-to-excel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243672374,"owners_count":20328762,"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":["excel","postgres","postgresql","xlsx"],"created_at":"2024-11-20T23:19:20.322Z","updated_at":"2026-05-20T02:49:20.775Z","avatar_url":"https://github.com/david1602.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pg-to-excel\n\nGenerates an excel file from a postgresql connection and a query file.\n\n## Parameters:\n\n```\nqueryfile, f            path to a query file, must be used if query is not specified        string\nquery, q                query as string, must be used if queryfile is not specified         string\noutputfile, o           path to the output file, will be defaulted to ${timestamp}.xlsx     string\nconstr, c               connection string, \u003cpostgres://user:password@host:port/database\u003e    string\n```\n\nQueryfiles and output files can both be defined relative or absolute.\n\n## Examples\n\nThe queries contain mixed examples, for example `-c \u003cvalue\u003e` vs `--c \u003cvalue\u003e` vs `-c=\u003cvalue\u003e` vs `--c=\u003cvalue\u003e` to demonstrate that all of them are possible. You can substitute one with the other.\n\n### With a query file\n```\npg-to-excel -f query.sql -c 'postgres://user:password@localhost:5432/database'\n```\n\n### With a query\n```\npg-to-excel --q 'SELECT * FROM user' --c 'postgres://user:password@localhost:5432/database'\n```\n\n### With a specified output filename\n```\npg-to-excel -q='SELECT * FROM user' -c='postgres://user:password@localhost:5432/database' -o=test.xlsx\n```\n\n### Relative and absolute paths\n```\npg-to-excel --q=/opt/project/queryfile.sql --c='postgres://user:password@localhost:5432/database' --o=output.xlsx\n```\n\n\n## API\n\nThe API is also exposed with a function and can be called with `(queryFile, query, outputfile, connection)`.\nThe function is async and returns the output parameter, because I had no idea what to return. The file stream?\n\n```javascript\nconst run = require('pg-to-excel');\n\nconst query = 'SELECT * FROM user;';\nconst output = 'testfile.xlsx';\nconst constr = 'postgres://user:password@localhost:5432/database';\n\nrun(null, query, output, constr);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavid1602%2Fpg-to-excel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavid1602%2Fpg-to-excel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavid1602%2Fpg-to-excel/lists"}