33 lines
831 B
Bash
33 lines
831 B
Bash
#!/bin/bash
|
|
|
|
# Define database connection variables
|
|
db_host="your_db_host"
|
|
db_user="your_db_user"
|
|
db_pass="your_db_password"
|
|
db_name="your_db_name"
|
|
db_table="your_db_table"
|
|
|
|
# Define path to dictionary file
|
|
dictionary_file="path_to_your_dictionary_file"
|
|
|
|
# Check if dictionary file exists
|
|
if [ ! -f "$dictionary_file" ]; then
|
|
echo "Dictionary file not found."
|
|
exit 1
|
|
fi
|
|
|
|
# Function to insert word into the database
|
|
insert_into_database() {
|
|
local word="$1"
|
|
mysql -h "$db_host" -u "$db_user" -p"$db_pass" "$db_name" -e "INSERT INTO $db_table (word) VALUES ('$word');"
|
|
}
|
|
|
|
# Loop through each word in the dictionary and insert it into the database
|
|
while read -r word; do
|
|
insert_into_database "$word"
|
|
echo "Inserted word $word into database."
|
|
done < "$dictionary_file"
|
|
|
|
echo "All words inserted into database."
|
|
|