Comments (5)
This is happening as a socket cannot be created to establish a connection ( for same reason you cannot use library such as requests). The web assembly doesn't support native sockets AFAIK
from pyscript.
Would it be an idea to repurpose this to documentation describing how to interact with databases?
from pyscript.
Would it be an idea to repurpose this to documentation describing how to interact with databases?
This is definitely an interesting topic for the "How to" part of the docs.
I guess we can repurpose this issue to point to that.
In case anyone wants to tackle it, feel free to reach out to me.
We have docs on how to build the docs, and good "how to" examples that were contributed by the community in the past.
Maybe one of the docs that'd be relevant to this issue is: How to make HTTP requests using PyScript, in pure Python
from pyscript.
Hi @PartikIITD and everyone,
As mentioned earlier, using sockets directly to connect to databases like MySQL is not possible in the current setup due to the limitations of web assembly. However, you can still interact with databases using alternative methods, such as making API calls to a server-side script that handles the database operations.
For instance, you can create a server-side script (using Flask, Django, or any other preferred framework) that interacts with the MySQL database, and then expose an API endpoint to perform the required database operations. Next, use PyScript to make HTTP requests (GET, POST, etc.) to these API endpoints to perform the desired tasks.
Here's a high-level outline of the steps:
- Develop a server-side script (e.g., in Python, PHP, or Node.js) that connects to the MySQL database and performs the necessary operations.
- Expose API endpoints for the server-side script to perform CRUD operations on the database.
- Use PyScript to make HTTP requests to the API endpoints to interact with the database indirectly.
I hope this helps! Please let me know if you have any questions or need further assistance.
from pyscript.
PyScript works on the browser, where it's hard to install MySQL or PostgreSQL in any meaningful way so sockets and libraries to connect via sockets or REST API is needed.
However, I think sqlite would work out of the box, but it would likely be an in-memory (hence volatile) solution.
There are JS libraries that persist SQLite on the browser and maybe there's something in the Python Web world too, but this is how it works and there's no action for us to take directly.
Closing for the mentioned reason.
from pyscript.
Related Issues (20)
- <script type="py" terminal worker> not working in chrome HOT 3
- Weird float arg bug on MicroPython when calling a JS method HOT 11
- PyScript.com fails to highlight extensions .mjs & .cjs HOT 5
- Output from python code in HTML is not getting rendered, it is only getting rendered as js in the browser console. I'm using PyScript link. HOT 2
- Triple quotes throws error in pyscript. HOT 8
- Cannot cancel multi-cursor editing with the keyboard HOT 7
- In the code editor ctrl+enter does not create a new line below HOT 3
- `PyDom[key: int]` raises `AttributeError: 'int' object has no attribute 'indices'`
- Terminal does not show error message when using workers HOT 2
- Py Terminal issues aggregation HOT 1
- PyScript pre-resolved config URL is not consistent
- the py-editor is created repeatedly HOT 13
- MicroPython doesn't support MethodType() from "types" module! HOT 1
- MicroPython doesn't support alternative syntax to create a tuple outta comprehension HOT 1
- MicroPython should provide better error messages for missing APIs HOT 8
- Alert box issue. HOT 3
- Error message not shown. HOT 6
- terminal with worker not working HOT 2
- Saved Image not Displayed. HOT 4
- Incorrect line number in exception tracebacks HOT 18
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyscript.