Hi @yashshingvi
Welcome to the forum
What you’re running into is a common question - there’s a bit more detail in this previous answer i gave to a very similar question here: Connecting to databases using sqlalchemy - #2 by neil
In essence, everything in PyScript is running inside the browser inside the sandbox it imposes, thus you’re unable to run the code successfully because it cannot establish a connection (the sandbox blocks it establishing a socket to your database outside sandbox)
In theory there could be ways to get around this, if you were to construct a web accessible API to your database, because API calls can be made out of the sandbox, but it would need a bit of work.