シナリオ: 小さなシェル スクリプト プログラムを試しています。
このプログラムでは、2 つのテーブルを持つデータベースにクエリを実行しようとしています。はいまたはいいえの答えを得ようとします。
etag = md5sum
Pythonスクリプトを使用してファイルから取得したもの。
echo 'select a.hash,b.hashuser, case when a.hash=b.hashuser then "No!" else "yes!" end from tempo b, hashes a where a.hash=b.hashuser and b.hashuser='$etag''
画面に印刷しようとすると、etagがmd5sumとして明確に表示されます
しかし、データベースでクエリを実行して結果を取得しようとすると。以下のスクリプトを使用して
sqlite3 hashez.db 'select a.hash,b.hashuser, case when a.hash=b.hashuser then "No!" else "yes!" end from tempo b, hashes a where a.hash=b.hashuser and b.hashuser='$etag''
これは私が得るエラーです。
Error: unrecognized token: "579f0b61cf958a0eea2f60906e6a04a4"
少しグーグルで調べた後、これはこのリンクから見つけた解決策です
それから私はそれを${#etag}
echo 'select a.hash,b.hashuser, case when a.hash=b.hashuser then "No!" else "yes!" end from tempo b, hashes a where a.hash=b.hashuser and b.hashuser='${#etag}''
私が今得るエラーは
select a.hash,b.hashuser, case when a.hash=b.hashuser then "No!" else "yes!" end from tempo b, hashes a where a.hash=b.hashuser and **b.hashuser=32**
なぜ b.hashuser=32 なのですか。私の最初の質問です。
2番目の問題:
上記の関数を使用してデータベースにクエリを実行しようとすると:
sqlite3 hashez.db 'select a.hash,b.hashuser, case when a.hash=b.hashuser then "No!" else "yes!" end from tempo b, hashes a where a.hash=b.hashuser and b.hashuser='${#etag}''
返信がありません。
- 私のクエリは間違っていますか?、はいの場合、データベースで直接クエリを実行したときに回答が得られるのはなぜですか?
私の悪い英語でごめんなさい