APK file is crashing when I access mysql database - python

I can access MySQL on my other laptops at home, but when I converted my py file to apk, my app crashed when I hit the button connected to my database. I put my computer IP (host) in the code and gave all privilege grants to that user. I have also given permission to the internet in the buildozer.spec file. Still my application is crashes, what should I do?
I tried accessing mysql data to my other computers at home they work fine, but here I am creating an applications with kivy python its crash when I try to access database. I am using IP address to connect to data base and also check that there is not firewall. I am using macbook air and trying to run my apk file into one plus which is running android 12.
Link for my all code & [android debug file]
https://github.com/kushp15/PY-to-APK

There you have your error
And the solution to it is providing mysql-connector-python in buildozer requirements.
There has been a similar issue.

Instead of using mysql_connector_python, I switch to pymysql which worked correctly, and in buildozer instead of mysql_connector change to pymysql. Thats it, It works. I have updates on my github page. Link: https://github.com/kushp15/PY-to-APK

Related

VS Code connecting to jupyterlab server not selecting kernel

We have recently moved to a JupyterLab Server from another IDE. We are trying to get VS Code hooked up so that we can code in it rather. After much struggle, we got VS Code to connect to our remote JupyterLab server. On the status bar in the bottom, it shows
However, as soon as we connect to the JupyerLab server, all the 'run' buttons on screen disappears.
We are getting no support from our IT and have to figure it out ourselves.
A colleague suspects that it (VS Code) is not picking up the python kernel from the server. How do we go about selecting it? or pointing to it?
An additional question, how do we see and browse the folders on the JupyterLab server in VS Code?
Appreciate any assistance
I think the problem is that you didn't really connect to the remote server.
Install Remote-SSH extension. Then you can see the button on the bottom left. Click and you can connect to your service and view your folder.
You can read document about Remote-SSH for more details/
Connect to a remote Jupyter server.
According to the document about jupyter, you have to do the following steps:
Open the Kernel Picker button on the top right-hand side of the notebook (or run the Notebook: Select Notebook Kernel command from the Command Palette).
Select the Existing Jupyter Server option to connect to an existing Jupyter server.
To connect to an existing server for the first time, select Enter the URL of the running Jupyter server.
When prompted to Enter the URL of the running Jupyter server, provide the server's URI (hostname) with the authentication token included with a ?token= URL parameter. (If you start the server in the VS Code terminal with an authentication token enabled, the URL with the token typically appears in the terminal output from where you can copy it.) Alternatively, you can specify a username and password after providing the URI.

How to Host a Flask website from localhost 5000

Hello I coded this website that generates math problems (Here is the code: Here)
It is coded on flask and it is locally being hosted on this link that is not accessible to other people http://127.0.0.1:5000/ .I have a google domain and I want to have a website. What things / services do I need to use. I have been wait to see if I need to use AWS but I think I might need to. I have tried things like transferring it off of flask but I can't. If this is a repost sorry please post there answer thanks -Ben
I am assuming what you're asking is to host your flask web site so others can view it. The address you mention in your post is the local host address for your computer and is only accessible from your own computer. If you only want someone on your same network (WiFi) to access it, you would need to replace "127.0.0.1" with the IP address of your computer. You would also likely have to open up a firewall on your computer to allow the port 5000.
However, if you want anyone on the internet to access your site, there are a ton of ways to do this but since you mentioned AWS, you can do this easily by running a small EC2 instance (virtual server). If you have a new AWS account and have not already run any EC2 in that account, you can actually run a small EC2 instance for free for a whole year. Great for small projects. If you're just getting started with EC2, you may want to go here https://aws.amazon.com/ec2/getting-started/
Basic steps:
Spin up an EC2 instance. Choose the default Amazon Linxu 2 OS type, make sure to create/assign a key pair so you can later ssh into it, make sure the Allow SSH from anywhere setting is checked/selected and the Allow HTTP checkbox is checked (not HTTPS).
Wait for the instance to launch.
Log into your instance by clicking on your ec2 instance in the list of ec2 instnaces and click the Connect button, click the Connect button again (Instance connect tab). If that doesn't work, follow the steps on the SSH client tab.
Install flask
pip3 install flask
Clone your git repo
git clone https://github.com/some0ne14/Math-Ibex.git
Change to your repos' folder
cd Math-Ibex/Math-Practice-Website-master
Edit your main.py so that the app.run line looks like the following (you can do this on GitHub before you run git clone actually or use the nano command to edit the file easily). This allows the system to run on the standard web port 80.
app.run(host='0.0.0.0', port=80, debug=True)
Run the following to start the application. If you want to run it as a service so you can walk away or close the terminal and it will still stay running, just search on here how to run flask as a service.
python3 main.py
You can now connect to your server with any web browser using your EC2 instance's public IP address or generated AWS DNS name (available on the EC2 instnace property page).
Make sure to stop your instance when not using it to save those free runtime minutes.

Access denied with remote mysql connector python3 connection

Connection problem solved! Leaving for others who may have issue.
Still having problems with bind-address issues
I will state the problem, the loayout context of my system and things I have tried.
Problem: When trying to use mysql connector in a python file i keep getting access denied. I am using Pycharm as my IDE and I have the Mysql connector installed though that.
So I am running Ubuntu Server on a Orale VM on a Windows 10 desktop, it's a bridged connection and I can SSH in from my laptop (LInux Mint)to the server just fine. I am running the program trying to access the DB on the Linux Mint laptop. Local network only using 192.168.0.xxx protocols. All VPN's disabled at this point for now.
So just to state i reinstalled the server last night and I set up fresh users and DB for the user and even granted ALL PRIVILEGES to the user and connections from my connectiong machines.
i set bind address in my mysqld.cnf file to 0.0.0.0 for now.
(when i had it set to my laptop ip it wouldn't bind and would restart until I switched it back)
UFW is set to allow mysql(3306)
Ask all the questions and I will get you answers asap. Please provide commands for me to run if needed and specify if the should be ran on the server or my laptop. Thanks for reading!

Do I need to install MySQL Server on client machine, the database is used (Read, Write, Delete) by Python script I wrote?

I have written a python script that uses the MySQL Connector for Python to read, write and update the database. Do I need to install MySQL server on the client machine (Windows) too to run the program or do I just need to make sure that the database is present in the path used by the script? I tried finding guidance on Google and here but couldn't find what I needed.
No you don't need to install MySQL Server on a client machine. By definition client machine means you don't have the DB/Server there. Where is this DB allocated? You show have an IP or a domain/subdomain address where the DB is actually hosted.

Permission denied when django writes to external device

I have a django file server. The server works perfectly on my laptop & localhost (with external hard drive) but when I transferred it to my Raspberry Pi running Raspbian, it starts acting up.
I did a lot of googling and tried every possible solution but it does not work.
Here is my problem:
I have connected an external hard drive to my raspberry pi. I believe it has write permissions because I can easily write to it with mkdir. I have also set this directory which is /media/pi/SAMSUNG/media as my MEDIA_ROOT.
Now I have set up Apache2, WSGI and Django, everything works, I have set up all the permissions and everything, but still when django tries to access the hard drive, whether it be to read or write, I get an error [Errno 13] Permission denied: '/media/pi/SAMSUNG'.
I have fixed this in the past with chown -R 777 but it does not work this time.
Unfortunetly, I have no idea what I am doing when it comes to servers and file permissions, so I have no idea what code to attach. Can some please help me?
I will attach all the necessary code on request.
Thank you
On raspbian you have to be careful when using external drives. Have you edited the file /etc/fstab? This is necessary to mount the drive also correctly after restarts and when the file is temporarily disconnected and then connected again.
If you did this correctly, then the drive will have the permissions you gave it when mounting and Django should be able to access it/write to it.
BR

Categories