![]() |
Access online database from python - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Access online database from python (/thread-1311.html) |
Access online database from python - d4py - Dec-23-2016 Hi, I am learning python at the moment (codeacademy & learn python android app & a couple of different books) and am also making little programs as I progress along... One that I have made currently is a little acronyms dictionary that uses pickle and a .p file to store the dictionary. However when new words are added by myself they obviously do not show up on the version that I have sent a friend (unless I send her the .p file) What I'd love to do is store the dictionary online and let it be updated by both of us. I was thinking about using an online database perhaps.. is this the way you'd do it? I've made an attempt at using pymysql on a .py on my PC but I can't seem to connect to the database on my hostmonster account. Am I right in thinking I'd need something other than localhost here? As surely it needs a webaddress in that field to know where the database is? Any steer in the right direction would be really appreciated! Many thanks D RE: Access online database from python - buran - Dec-23-2016 Your host provider needs to give you details how to connect to the DB. localhost is alias for server running on your local machine, so if you run the script on your local machine it probably will run, however your friend it will try to connect to server (localhost) on his machine. RE: Access online database from python - d4py - Dec-23-2016 Many thanks for the help... They provide this page for remote database connection.. https://my.hostmonster.com/cgi/help/89 Is this what I need to look into? For host name, it says "use the server IP address".. however, I'm not sure where to find that.. I will ask hostmonster for that info if you think this is the right way to do it.. One thing I see on that page is that I need to add an IP to gain access.. it would be nice if I wasn't bound to certain computers to use it.. RE: Access online database from python - buran - Dec-23-2016 yes, that's the what you have to look for. contact the support if not able to locate the IP. Note that you have to white-list the IP address if you want to connect to the database remotely. If you have website hosted on they use localhost in the connection string. If that's a problem you may want to look for different host. RE: Access online database from python - snippsat - Dec-23-2016 Flask and DigitalOcean(host of this site) is a good choice. You may need to spend some time learning this stuff. Hostmonster is terrible for Python,and cost more than DigitalOcean. Other Python friendly hosts PythonAnywhere, Heroku. RE: Access online database from python - d4py - Dec-23-2016 Really appreciate the help everyone. Many thanks I spoke to them and yes the server IP is the shared IP written on the home page of my account.. I've whitelisted my home IP.. and can now load and save a dictionary correctly between the database and python! However, I feel now the difficulties begin! What would be the best way to organise this.. I'm thinking that the simplest way would be to have upload / download buttons.. The easiest (but most dangerous?) way would be: when upload is pressed, delete all the entries on the remote server and replace them with all the entries of the local dictionary and vice versa for download. (could something go wrong here and lose everything?) Would it be better to do it on a one by one basis.. ie. upload would look through local dictionary and remote dictionary.. ignore if on both.. but add an entry if in local_dict but not on remote_dict... etc... PS.. thanks I will look into other hostings eventually.. I've always been happy with hostmonster personally as I have only needed a very basic html/css website. Perhaps that will change now I've started to learn to code.. I suppose instead of a .exe file running the python script.. I could have made the program on a web page.. and then I could have used the "local" host setting? Is this what you mean by hostmonster being no good for that? Is it not possible to do something like that on hostmonster? |