Skip to content

Instantly share code, notes, and snippets.

@danthelion
Created March 21, 2024 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danthelion/30d4e1fda39a27983e5d3a2e6d1f3b28 to your computer and use it in GitHub Desktop.
Save danthelion/30d4e1fda39a27983e5d3a2e6d1f3b28 to your computer and use it in GitHub Desktop.
set -e
DB_FILE_FULL_PATHG=$1
DB_FILE_PARENT_FOLDER=$(dirname $DB_FILE_FULL_PATHG)
DB_FILE_NAME=$(basename $DB_FILE_FULL_PATHG)
ngrok http file://$DB_FILE_PARENT_FOLDER --log=stdout >/dev/null &
sleep 1
PUBLIC_URL=$(curl -sS http://localhost:4040/api/tunnels | jq -r '.tunnels[0].public_url')
NGROK_URL="$PUBLIC_URL/$DB_FILE_NAME"
echo "Database file $DB_FILE_NAME is now being shared, to connect in DuckDB execute:"
echo "> load httpfs; attach '$NGROK_URL';"
echo "To kill the share, execute:"
echo "> kill -9 $(ps aux | grep ngrok | grep -v grep | awk '{print $2}')"
@danthelion
Copy link
Author

./duckdb-share.sh path/to/duck.db

Database file test.db is shared, to connect in DuckDB execute:
> load httpfs; attach 'https://d3a0-209-35-224-123.ngrok-free.app/duck.db';

To kill ngrok, execute:
> kill -9 42114

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment