バインディングパラメータとして絶対ファイルパスを使用しようとしています。ただし、構文エラーがスローされます。
exports.up = async (knex: Knex): Promise<any> => {
const dest2 =
'/Users/ldu020/workspace/github.com/mrdulin/nodejs-pg-knex-samples/src/knex-migration/using-a-remove-csv-file/migrations/geotargets-2019-05-02.csv';
await knex.raw(
`
copy t1_geotargets(criteria_id, criteria_name, canonical_name, parent_id, country_code, target_type, status)
from ?? DELIMITER ',' CSV;
`,
[dest2]
);
};
エラーメッセージは次のとおりです。
migration file "20190515121901_import-a-remote-csv-file.ts" failed
migration failed with error:
copy t1_geotargets(criteria_id, criteria_name, canonical_name, parent_id, country_code, target_type, status)
from "/Users/ldu020/workspace/github"."com/mrdulin/nodejs-pg-knex-samples/src/knex-migration/using-a-remove-csv-file/migrations/geotargets-2019-05-02"."csv" DELIMITER ',' CSV;
- syntax error at or near ""/Users/ldu020/workspace/github""
どうすればこれを解決できますか?
更新
私は問題を見つけたと思います。理由は.
シンボルです。しかし、それを処理する方法がわかりません。
識別子のバインド期間はテーブル名と列名の区切り文字として解釈されるため、これは不可能です。
あなたはそれを手動で入力する必要があります knex.raw(`... from "${dest2}" DELIMITER ...`)
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加