Jump to content

How To Work With Postgress + Django On Tommy.


Recommended Posts

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 DB

MongoDB (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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by patents
Link to comment
Share on other sites

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 by patents
Link to comment
Share on other sites

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)
Link to comment
Share on other sites

What is username and password? cpannel or created in mysql wizard?

 

I just created demo username and password from cpannel mysql wizard.

 

db = patents_demodb

user=patents_demousr

pass=demopass

 

if you have local python, and mysql driver, can you try this for me please?

 

import MySQLdb
myDB = 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 by patents
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...