Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

FR: support environment variables in (favourite) queries

未关闭
#163 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
30/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
python, sqlite
领域
cli, database

调研方向

首先定位 litecli 对收藏查询的处理方式以及 \f 命令的入口点;该 issue 未指定源文件或测试。阅读现有 $1/$2 参数是如何替换的,然后明确环境展开仅适用于收藏查询,还是适用于所有查询。只要约定的语法能够在所示的数据库变体中正常工作,且不破坏现有查询参数,就算完成。

由索引模型根据 Issue 内容生成。

描述

I'd love to see support for using environment variables in favourite queries, or even in all queries.

The use case is that I have several very similar databases where favourite queries all need to take a parameter to indicate what 'variant' of the database I'm currently using, or I have to copy configuration files for each database file and alter one value in each query filter.

Say, the different values are 'foo' and 'bar', and I have to either do:

favquery1 = '''select ...
    from some_table
    where parameter='$1'
    and other_paramater='$2'
'''
favquery2 = '''select ...
    from some_other_table sot inner join a_third_table att on sot.id = att.sot_id
    where sot.parameter='$1'
    and att.column_name ='$2'
'''

and then run \f favquery1 foo 42 and \f favquery2 bar 45, or I copy the configuration file multiple times and hardcode the parameter in each.

If, instead, I could use environment variables (syntax suggestion, feel free to come up with better syntax, this is based on bash):

favquery1 = '''select ...
    from some_table
    where parameter='${PARAMETER}'
    and other_paramater='$1'
'''
favquery2 = '''select ...
    from some_other_table sot inner join a_third_table att on sot.id = att.sot_id
    where sot.parameter='${PARAMETER}'
    and att.column_name ='$1'
'''

and then start each litecli instance with a different environment variable and use the exact same favourites for each database:

$ PARAMETER=foo litecli foo_database.sqlite
foo_database.sqlite> \f favquery1 42

and

$ PARAMETER=bar litecli bar_database.sqlite
bar_database.sqlite> \f favquery1 42
主要语言
Python
星标
3.3k
派生
95
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

dbcli/litecli 的其他 Issue

查看 dbcli/litecli 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。