{"id":14563573,"url":"https://github.com/anki-code/localsql","last_synced_at":"2025-07-02T21:32:46.344Z","repository":{"id":62576569,"uuid":"261252736","full_name":"anki-code/localsql","owner":"anki-code","description":"Querying csv, xlsx, json local files using SQL as easy as possible.","archived":false,"fork":false,"pushed_at":"2024-04-01T18:40:47.000Z","size":45,"stargazers_count":5,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T15:21:17.122Z","etag":null,"topics":["csv","csv-files","csv-import","json","json-schema","localsql","pandas","sql","sqlite","sqlite-database","sqlite-extension","sqlite3","xls","xlsx"],"latest_commit_sha":null,"homepage":"","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/anki-code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"custom":["https://github.com/anki-code","https://www.buymeacoffee.com/xxh","https://github.com/xonsh/xonsh#the-xonsh-shell-community"]}},"created_at":"2020-05-04T17:34:18.000Z","updated_at":"2025-03-12T05:22:38.000Z","dependencies_parsed_at":"2024-01-31T12:11:14.504Z","dependency_job_id":null,"html_url":"https://github.com/anki-code/localsql","commit_stats":null,"previous_names":["localsql/localsql"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/anki-code/localsql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Flocalsql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Flocalsql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Flocalsql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Flocalsql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anki-code","download_url":"https://codeload.github.com/anki-code/localsql/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Flocalsql/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263218319,"owners_count":23432472,"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":["csv","csv-files","csv-import","json","json-schema","localsql","pandas","sql","sqlite","sqlite-database","sqlite-extension","sqlite3","xls","xlsx"],"created_at":"2024-09-07T02:03:24.803Z","updated_at":"2025-07-02T21:32:46.295Z","avatar_url":"https://github.com/anki-code.png","language":"Python","readme":"\u003cp align=\"center\"\u003e\n\u003cb\u003eLocalSQL\u003c/b\u003e is for querying local csv, xlsx, json files using SQL. \n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e  \nIf you like the idea click ⭐ on the repo and stay tuned.\n\u003c/p\u003e\n\n## Install\n```bash\npip install git+https://github.com/anki-code/localsql\n```\n\n## Usage\n\n```xsh\nlsql --help\n# usage: lsql [-h] [-d DIRECTORY] [-r] [-q QUERY] [-v] [-s] [-jn] [--version] [files [files ...]]\n#\n# Querying local files using SQL.\n#\n# positional arguments:\n#   files                 Files with tables: csv, xlsx, json.\n# \n# optional arguments:\n#   -h, --help            show this help message and exit\n#   -d DIRECTORY, --directory DIRECTORY\n#                         Search files in this directory.\n#   -r, --recursive       Search files in the directory and subdirectories.\n#   -q QUERY, --query QUERY\n#                         Run SQL query and return result.\n#   -v, --verbose         Verbose mode.\n#   -s, --silent          Silent mode.\n#   -jn, --json-normalize\n#                         JSON normalize.\n#   --version, -V         show program's version number and exit\n```\n\n### SQL syntax\nLocalSQL uses [SQLite syntax](http://www.sqlite.org/lang.html).\n\n## Use cases\nTo repeat the use cases get the repository:\n```xsh\ncd ~ \u0026\u0026 git clone --depth 1 https://github.com/localsql/localsql \u0026\u0026 cd localsql\nlsql -d examples\n# examples/one.json: table=one_json, columns=4, rows=3\n# examples/lines.json: table=lines_json, columns=3, rows=3\n# examples/nested.json: table=nested_json, columns=5, rows=3\n# examples/excel.xlsx: table=excel_xlsx, columns=3, rows=5\n# examples/csv.csv: table=csv_csv, columns=3, rows=3\n# lsql\u003e\n```\n\n### Interactive\n```sql\nselect * from excel_xlsx\n#    id   b   c\n# 0   1   6  11\n# 1   2   7  12\n# 2   3   8  13\n# 3   4   9  14\n# 4   5  10  15\n\nSELECT * FROM excel_xlsx e LEFT JOIN one_json j ON e.id = j.id\n#    id   b   c   id    b    c    d\n# 0   1   6  11  1.0  4.0  NaN  NaN\n# 1   2   7  12  2.0  NaN  5.0  NaN\n# 2   3   8  13  3.0  NaN  NaN  6.0\n# 3   4   9  14  NaN  NaN  NaN  NaN\n# 4   5  10  15  NaN  NaN  NaN  NaN\n```\n### Not interactive\n```xsh\nlsql -d examples -q \"SELECT c, count(*) as cnt FROM one_json GROUP BY c ORDER BY 1 ASC NULLS LAST\" -s\n#      c  cnt\n# 0  5.0    1\n# 1  NaN    2\n```\n\n### Transpose output\nTo transpose the output add `/t` to the end of query:\n```sql\nSELECT * FROM nested_json LIMIT 1 /t\n# id                1\n# nest.a            1\n# nest.b    [1, 2, 3]\n# nest           None\n# c              None\n# Name: 0, dtype: object\n```\n\n### Python mode\n```python\n\\lpy\nprint(self.tables['csv_csv'])\n#    id  b  c\n# 0   1  4  7\n# 1   2  5  8\n# 2   3  6  9\n```\n\n### Pretty print\n\n```sql\n\\pp\n# Pretty print ON\nselect * from one_json\n# ╭─────┬─────┬─────┬─────╮\n# │  id │   b │   c │   d │\n# ├─────┼─────┼─────┼─────┤\n# │   1 │   4 │ nan │ nan │\n# │   2 │ nan │   5 │ nan │\n# │   3 │ nan │ nan │   6 │\n# ╰─────┴─────┴─────┴─────╯\n```\n\n## Known issues\n\n### Error: Not an executable object\n\nDowngrade `sqlalchemy` package i.e. `pip install 'sqlalchemy\u003c2'`.\n","funding_links":["https://github.com/anki-code","https://www.buymeacoffee.com/xxh","https://github.com/xonsh/xonsh#the-xonsh-shell-community"],"categories":["sqlite"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanki-code%2Flocalsql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanki-code%2Flocalsql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanki-code%2Flocalsql/lists"}