patents Posted October 15, 2017 Posted October 15, 2017 Does anybody uses postgress (or any database) with django (ORM). I am struggling as there is no shell access. I don't know if it is possible to use django ORM on heliohost.
Bailey Posted October 15, 2017 Posted October 15, 2017 In the file: myproject/settings.py. DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'database.sql', 'USER': '', 'PASSWORD': '', 'HOST': '', 'PORT': '', } } Database is set in the Database dictionary. The example above is for SQLite engine. As stated earlier, Django also supports − MySQL (django.db.backends.mysql)PostGreSQL (django.db.backends.postgresql_psycopg2)Oracle (django.db.backends.oracle) and NoSQL DBMongoDB (django_mongodb_engine)Before setting any new engine, make sure you have the correct db driver installed. from https://www.tutorialspoint.com/django/django_creating_project.htm Im not sure if it works but Im currently learning Django and this seems to be useful...
patents Posted October 16, 2017 Author Posted October 16, 2017 (edited) I am talking about practical approach not theory. Are you using it yourself? Once you set your models, How would you do migration? how you use it? Edited October 16, 2017 by patents
Krydos Posted October 16, 2017 Posted October 16, 2017 The easiest way to do anything django related is to develop on your home computer, migrate and all that locally. What I do is enable remote database connection and then have both the local and server version of django use the host tommy.heliohost.org. That way whether you're testing it on your home computer or running it on the server it uses the same database.
patents Posted October 16, 2017 Author Posted October 16, 2017 (edited) I tried but for me the remote mysql is not working for my computer. This is my database setting for remote mysql. I added % in the allowed host. DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'patents_mypolls', 'USER': 'patents_mypollsu', 'PASSWORD': 'mypass', 'HOST': 'tommy.heliohost.org', 'PORT': '3306', } } This is my remote Mysql allowed hosts: Access Hosts %65.19.143.6 I get error: django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on 'tommy.heliohost.org' (10060)")I think the port 3306 is blocked on my computer and I don't know how to fix it. I am on windos 7. Edited October 16, 2017 by patents
Krydos Posted October 16, 2017 Posted October 16, 2017 Does this link work? http://portquiz.net:3306/ If you see text it means your computer can connect on outbound tcp port 3306.
patents Posted October 17, 2017 Author Posted October 17, 2017 (edited) I can see that page. I was checking weather I had access to port but could not find any solution. Thanks. I tried manually connecting using: import MySQLdb myDB = MySQLdb.connect(host="tommy.heliohost.org",port=3306,user="patents_mypollsu",passwd="XXXXX",db="patents_mypolls")but it gives same error: OperationalError: (2003, "Can't connect to MySQL server on 'tommy.heliohost.org' (10060)")Also tried host="65.19.143.6" but again same error. I don't know what is the matter. On searching the internet I came to know that 10060 is related to remote access. It means that the remote access is not enabled.I added % in my remote mysql db on cpannel tab. Is there anything else i need to do? Thanks. Edited October 17, 2017 by patents
Krydos Posted October 17, 2017 Posted October 17, 2017 Try allowing remote connections from your specific IP. You can find it by going to https://www.heliohost.org/ip.php
patents Posted October 18, 2017 Author Posted October 18, 2017 It doesn't work. Same Error. This is also open issue. https://www.helionet.org/index/topic/27644-tommy-mysql-remote-connections-not-working/. It seems there is something wrong with remote database on tommy.
Krydos Posted October 18, 2017 Posted October 18, 2017 I just tested remote mysql connection on Tommy and it works for me. # mysql --user=krydos --host=65.19.143.6 -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2374234 Server version: 5.6.35 MySQL Community Server (GPL)
patents Posted October 18, 2017 Author Posted October 18, 2017 (edited) What is username and password? cpannel or created in mysql wizard? I just created demo username and password from cpannel mysql wizard. db = patents_demodbuser=patents_demousrpass=demopass if you have local python, and mysql driver, can you try this for me please? import MySQLdbmyDB = MySQLdb.connect(host="65.19.143.6",port=3306,user="patents_demousr",passwd="demopass",db="patents_demodb") I shall delete the same after confirmation. Edited October 18, 2017 by patents
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now