Forums

External console IP adress

Hi everyone!

I'm currently trying to connect to an External MySQL server with a python console. The MySQL server has a "firewall" which denies all external connections, until the IP adress of the external connection (in this case my PythonAnywhere console) is added to the allowed connections list.

How can I find out the address of my console, or my running application to add it to the MySQL server's firewall? Or is there any other solution that would result in a fix IP address which can be allowed by the MySQL server?

Thank your very much in advance for your help!

David

I'm afraid there's not much we can do about that. Each of your consoles could have a different IP address and your web apps will have other IP addresses and all of them can change depending on what we're doing to manage load on PythonAnywhere.

Thank you for the fast answer, are there also new IP addressees from time to time? Just if there is a fixed number we could maybe add all of them to the allowed list. Also, is there a way to use a proxy server to connect to external mysql and then the IP would be the proxy's IP? Or am I totally wrong with this idea? :)

Presumably this is a 'public-facing' corporate MySQL server?

This might be a case where you're better off running Python on your own machine, which maybe has a more stable IP address.

Also, if you -can- use your own machine, it might help to establish a VPN connection from it to the corporate network.

Jim

Thank you Jim for the answer, sadly this is not the case, I am trying to connect to a MySQL server, which is on a shared hosting server (Bluehost actually).

But now that we are talking about this, I have a new idea, if I would run the MySQL server here on PythonAnywhere would it be possible to connect to the MySQL from the other website (with javascript maybe)? Also if I run the script here would the database be considered local, I mean there would be no bandwidth used when I transfer data to the database?

David

Hmm, I'm not 100% sure what you're trying to achieve! Better one site than two?

You could make a MySQL database at PA accessible via (for example) a simple Web2py app running on PA - just don't forget to secure each method you expose (easy in web2py).

When you say " from the other website (with javascript maybe)", are you talking about server or browser code?

Browser code, because we run a Joomla site where user input should write in the same database where the Python codes run. We use Joomla for it's modules and user access controls, therefore I wouldn't really want to change on that part, because I think these would be more complicated if we write the whole site code.

Actually the Joomla site should write into a user master table, then a Python script would run based on the user master data and store data in another table based on that, which would appear for the user in the end. That is the plan, but nothing is totally sure right now we are just testing how we could achieve this.

Do you think I'm over-complicating this problem? Thank you very much for your suggestions!

I'm still not sure what you're trying to achieve, so let me rephrase it and see if I've got it right:

You have a Joomla site with a MySQL database running on Bluehost and you want some Python code running on PythonAnywhere to access the data. Is that right?

If it is, there are a few more questions: What does the Python script do with the data? Does it process it and put it some new data back into the database?

I see Bluehost supports Python - wouldn't that be the way to go as you want to continue with Joomla as your CMS?

glenn: You are right! Actually the Python script saves text from the web based on the user's preferences, then it saves the whole data in SQL. Then a part of the SQL data is displayed in the Joomla site, that is the main idea.

jgmdavies: You are right, i didn't see it supports Python, but I'm really not sure, if it worth it, I mean here in PA I can access the codes easily, and there is a console ready for running, I'm not really sure how to set up a working Python environment on my own on the Bluehost server, is that even possible to run a Python code continuously on a normal web hosting?

Hmm. It might be overly complicating, but perhaps you could write a simple web service that runs on the Joomla server and exposes the data that you want the Python code to be able to read, and provides a post URL where the Python code can post its results? It would need to be password-protected, of course, and I'd recommend you run it over HTTPS. That would definitely work, and might be a good thing if it allowed you to separate the two systems -- a web service is more loosely-coupled than direct database access.

On the other hand, it might easily be over-engineering... I don't want to tell you to not use PythonAnywhere, but perhaps the best thing for you to do is to see if Bluehost do support long-running or periodically-running Python tasks (some web hosts do, some don't) and if they do, just use them and drop us :-S

Hi, just signed up tp pythonanywhere, looking to do this exact same thing. Has this changed? I need to whitelist pythonanywhere ip address, otherwise this won't work. I used shared hosting at Hostgator, and I can run python there too, but it doesn't work properly. That's why I wanted to run python scripts from pythonanywhere instead.

Nothing changed, but now we have a help page about that (and possible solutions): https://help.pythonanywhere.com/pages/StaticIPForExternalWhitelists/

Thank you for the quick response. Looking at the options, they are either too expensive or too difficult for me, or not applicable. So sadly, pythonanywhere won't work for my particular needs.

OK -- sorry we couldn't help more!

oof

No worries, I understand. Thanks again for answering, I will definitely consider pythonanywhere for future projects.