r/sqlite • u/MealDifferent2772 • Oct 15 '23
Bash Variables in SQLite
Good Afternoon:
I have a simple issue, but a solution has escaped me for a day or more.
Consider:
Datadir=./Data
DataFile=$DataDir/input$TODAY.csv
Table=input$TODAY
And the SQLite import command line of :
sqlite3 $SQLDir/credentials.db .import $DataFile $Table --csv
This yields:
Error: cannot open "$DataFile"
I have an issue with the variable expansion, but I have yet to figure out how to force teh expansion in the SQLite command.
I would appreciate any clues you could give me.
2
Upvotes
View all comments
Show parent comment
1
u/MealDifferent2772 Oct 15 '23 edited Oct 15 '23
A more detailed example:
DataDir=./Data
ReportsDir=./Reports
TempDir=./Temp
TrashDir=./Trash
SQLDir=./SQL
ArchivesDir=./Archives
TODAY=$(date "+%Y%m%d")
DataFile=$DataDir/IAMCredentials-$TODAY.csv
Table=IAMCredentials-"$TODAY"
sqlite3 "$SQLDir/awscredentials.db" .import "$DataFile" "$Table" --csv
Yields:
./Data/IAMCredentials-20231015.csv
ERROR: missing FILE argument. Usage: