Having problems escaping speech marks to execute shell script

Hope someone can give me some help.

I’m trying to execute an terminal script on a specific file

sqlite3 com.plexapp.plugins.library.db “DROP index ‘index_title_sort_naturalsort’”

which is in this directory:

~/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/

PROBLEM 1
I think I need to get the directory in a variable as a posix filepath while escaping the forward slashes



set DirPath to POSIX path of "~/Library/Application\\ Support/Plex\\ Media\\ Server/Plug-in\\ Support/Databases/"

PROBLEM 2
Then I need to call the Do shell script command and append the file path so it finds the file and executes the sql command < this is not working either, I think the quotes are causing the problem

do shell script "sqlite3 " & DirPath & “com.plexapp.plugins.library.db” & " " & quote & “DROP index ‘index_title_sort_naturalsort/’”

Error is:
error “sh: -c: line 0: unexpected EOF while looking for matching `"’
sh: -c: line 1: syntax error: unexpected end of file” number 2

You don’t need to escape the path manually, there is quoted form of

set dirPath to POSIX path of (path to application support folder from user domain) & "Plex Media Server/Plug-in Support/Databases/"
do shell script "sqlite3 " & quoted form of (dirPath & "com.plexapp.plugins.library.db") & space & quote & "DROP index 'index_title_sort_naturalsort'" & quote

thanks so much!!!