I have a LiveBook where I’m connecting to a SQLite db as follows (clearing the db each time and starting fresh is intentional):
# Database setup and migration
db_path = "./path/to/dev_db.db"
db_config = [
database: db_path,
pool_size: 10,
stacktrace: true,
show_sensitive_data_on_connection_error: true
]
# Stop the existing Repo if it's running
if Process.whereis(Repo) do
Repo.stop()
:timer.sleep(100) # Give it some time to shut down completely
end
# Delete the existing database file
File.rm(db_path)
# Start the Repo with the new database
{:ok, _} = Repo.start_link(db_config)
This works well and Ecto can be used normally.
Is there some way to replicate this with the Kino_db smartcell? I’d like to be able to use the SQL Query smartcell, which requires that the database connection was made with a smartcell too.
Where I’m getting stuck is trying to replicate the {:ok, _} = Repo.start_link(db_config)
part to connect Ecto with the database process; start_link/0
wants to start a new process and I can’t see any alternative to use an existing process.
Is there a way to get Ecto to connect to the existing process created by the smartcell?