{"id":22870272,"url":"https://github.com/berquerant/dql","last_synced_at":"2025-03-31T11:26:08.537Z","repository":{"id":81890016,"uuid":"416434076","full_name":"berquerant/dql","owner":"berquerant","description":"Find files or directories by sql.","archived":false,"fork":false,"pushed_at":"2022-07-18T06:15:27.000Z","size":72,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-06T16:58:40.697Z","etag":null,"topics":["go","yacc"],"latest_commit_sha":null,"homepage":"","language":"Go","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/berquerant.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":"2021-10-12T17:28:33.000Z","updated_at":"2021-10-12T17:35:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"62567199-8e98-4951-b69c-83cf87a80c7c","html_url":"https://github.com/berquerant/dql","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/berquerant%2Fdql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berquerant%2Fdql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berquerant%2Fdql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berquerant%2Fdql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/berquerant","download_url":"https://codeload.github.com/berquerant/dql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246460299,"owners_count":20781084,"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":["go","yacc"],"created_at":"2024-12-13T13:14:22.690Z","updated_at":"2025-03-31T11:26:08.507Z","avatar_url":"https://github.com/berquerant.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dql\n\nFind files or directories by sql.\n\n## Syntax\n\n```\nSELECT select_expr [, select_expr ...]\n[WHERE where_condition]\n[GROUP BY col_name]\n[HAVING having_condition]\n[ORDER BY order_by_expr [ASC | DESC]]\n[LIMIT row_count [OFFSET offset]]\n```\n\n### SELECT\n\n`select_expr` is a column that you want.\n\n```\nselect name, size;\n```\n\nSelect all columns.\n\n```\nselect all;\n```\n\nis equivalent to\n\n```\nselect name, size, mode, mod_time, is_dir;\n```\n\nGive a temporary name:\n\n```\nselect name as N;\n```\n\nThe temporary name is available in `WHERE`, `HAVING` and `ORDER BY`.\n\nAggregations are available with conditions below:\n\na. without `GROUP BY` and select aggregations only.\nb. with `GROUP BY` then except `GROUP BY` column.\n\n### WHERE\n\n`where_condition` is a condition expr, if the evaluated value of a row is true then the row is selected.\n\n```\nselect all where is_dir;\n```\n\n### GROUP BY\n\n`GROUP BY` aggregates rows by `col_name`.\n`SELECT` must contain `col_name` and not contain raw columns but `col_name`.\n\n```\nselect is_dir, count(name) group by is_dir;\n```\n\n### HAVING\n\n`having_condition` is a condition expr, if the evaluated value of a row is true then the row is selected.\n`HAVING` must be written with `GROUP BY`.\n\n```\nselect mode, count(name) group by mode having count(name) \u003e 5;\n```\n\n### ORDER BY\n\n`order_by_expr` is a expr on which to sort rows.\n\n```\nselect len(name) as nlen, name order by nlen desc;\n```\n\n### LIMIT\n\n`row_count` constrains the number of the result rows.\n\n```\nselect all limit 3;\n```\n\nIf `offset` is exist, ignore first `offset` rows.\n\n```\nselect all limit 3 offset 5;\n```\n\n## Columns\n\n- `name` is the path.\n- `size` is the size, number of bytes in the file.\n- `mode` is the file mode, the entry type and permissions.\n- `mod_time` is the last modification time.\n- `is_dir` is the limited entry type, if true, the row comes from a file.\n\n## Data types\n\n| Name   | Description    | Example       |\n|--------|----------------|---------------|\n| int    | integer        | 10, -1        |\n| float  | floating point | 1.2, -0.5     |\n| string | string         | \"str\"         |\n| bool   | bool           | (no literals) |\n\nHereafter, int or float are referred to as number,\nand a string literal matched with `[01]+` is referred to as bits.\n\n## Operators\n\nThe operators in the more lower row has the higher precedence.\n\n| Format                | Description           | Argument Types            | Result Type | Example                     |\n|-----------------------|-----------------------|---------------------------|-------------|-----------------------------|\n| or                    | or                    | bool, bool                | bool        | is_dir or size \u003c 100        |\n| and                   | and                   | bool, bool                | bool        | is_dir and name = \"x\"       |\n| xor                   | xor                   | bool, bool                | bool        | size \u003c 100 xor name = \"x\"   |\n| =                     | equal                 | any, any (same type)      | bool        | name = \"x\"                  |\n| \u003c\u003e                    | not equal             | any, any (same type)      | bool        | name \u003c\u003e \"x\"                 |\n| \u003c                     | less than             | any, any (same type)      | bool        | size \u003c 100                  |\n| \u003c=                    | less than or equal    | any, any (same type)      | bool        | size \u003c= 100                 |\n| \u003e                     | greater than          | any, any (same type)      | bool        | size \u003e 100                  |\n| \u003e=                    | greater than or equal | any, any (same type)      | bool        | size \u003e= 100                 |\n| . in (...)            | within                | any, list of any          | bool        | name in (\"x\", \"y\")          |\n| . not in (...)        | not within            | any, list of any          | bool        | name not in (\"x\", \"y\")      |\n| . between . and .     | between               | any, any, any (same type) | bool        | size between 10 and 100     |\n| . not between . and . | not between           | any, any, any (same type) | bool        | size not between 10 and 100 |\n| . like REGEX          | matched string        | string, string            | bool        | name like \"log$\"            |\n| . not like REGEX      | not matched string    | string, string            | bool        | name not like \"log$\"        |\n| +                     | add                   | number, number            | number      | size + 1                    |\n| \\-                    | subtract              | number, number            | number      | size - 1                    |\n| \\*                    | multiply              | number, number            | number      | size * 2                    |\n| /                     | division              | number, number            | number      | size / 2                    |\n| \\|                    | bit or                | int or bits, int or bits  | int         | 3 \\| 4                      |\n| \u0026                     | bit and               | int or bits, int or bits  | int         | 3 \u0026 4                       |\n| ^                     | bit xor               | int or bits, int or bits  | int         | 3 ^ 4                       |\n| +                     | noop                  | any                       | any         | +1                          |\n| \\-                    | unary minus           | number                    | number      | -1                          |\n| ~                     | bit not               | int or bits               | int         | ~15                         |\n| not                   | not                   | bool                      | bool        | not is_dir                  |\n\n## Functions\n\nThe function converts an expr or a column into some value.\n\n| Format     | Description                      | Argument Types | Result Type | Example                  |\n|------------|----------------------------------|----------------|-------------|--------------------------|\n| pow(x, y)  | x to the power of y              | number, number | number      | pow(2, 3)                |\n| ceil(x)    | ceiling                          | number         | int         | ceil(2.3)                |\n| floor(x)   | floor                            | number         | int         | floor(2.3)               |\n| len(x)     | length of string                 | string         | int         | len(\"length\")            |\n| base(x)    | the last element of path         | string         | string      | base(\"dir/file\")         |\n| dir(x)     | all but the last element of path | string         | string      | dir(\"dir/file\")          |\n| ext(x)     | the file name extension          | string         | string      | ext(\"dired.elc\")         |\n| bin2int(x) | bits to int                      | bits           | int         | bin2int(\"1010\")          |\n| int2bin(x) | int to bits                      | int            | bits        | int2bin(10)              |\n| cast(x, y) | cast x to y                      | any            | string      | cast(10, \"string\")       |\n| now()      | the current local time           |                | int         | now()                    |\n| depth(x)   | the depth of the path            | name           | int         | depth(\"/home/user\")      |\n| grep(x, y) | `grep x y`                       | string         | string      | grep(\"lambda\", \"map.py\") |\n\n### Cast\n\n`cast(value, \"destination type\")` cast value to destination type.\n\nIf the type of the value equals the destination type, then the result is the value itself.\nMore conversion rules are below:\n\n| Value Type | Destination Type | Description                                                                  |\n|------------|------------------|------------------------------------------------------------------------------|\n| float      | int              | floor                                                                        |\n| string     | int              | parse                                                                        |\n| bool       | int              | true into 1, false into 0                                                    |\n| int        | float            | type conversion only                                                         |\n| string     | float            | parse                                                                        |\n| bool       | float            | true into 1.0, false into 0.0                                                |\n| any        | string           | format as string                                                             |\n| number     | bool             | value != 0                                                                   |\n| string     | bool             | value != \"\"                                                                  |\n| string     | timestamp        | parse string like \"2006-01-02T15:04:05Z07:00\" (RFC3339) into timestamp (int) |\n| number     | time             | timestamp into time (string)                                                 |\n| number     | duration         | seconds into duration (string)                                               |\n\nUndefined rules cause conversion errors.\n\n### Aggregations\n\nThe aggregation converts the rows into some value.\n\n| Format     | Description           | Argument Types | Result Type     | Example       |\n|------------|-----------------------|----------------|-----------------|---------------|\n| count(x)   | number of the rows    | any            | int             | count(name)   |\n| min(x)     | minimum of the rows   | any            | any (same type) | min(size)     |\n| max(x)     | maximum of the rows   | any            | any (same type) | max(name)     |\n| product(x) | product of the rows   | number         | number          | product(size) |\n| sum(x)     | summation of the rows | number         | number          | sum(size)     |\n| avg(x)     | average of the rows   | number         | number          | avg(size)     |\n\n## Reserved words\n\nThe reserved words are case insensitive.\n\n```\nselect where having group by order limit as asc desc like in not and or xor between offset\n```\n\n## Usage\n\n```\nmake dist/dql\ncd dist\ndql -h\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberquerant%2Fdql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fberquerant%2Fdql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberquerant%2Fdql/lists"}