Jump to content

Recommended Posts

Posted

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.

Posted

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

Posted (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 by patents
Posted

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.

Posted (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 by patents
Posted (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 by patents
Posted

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)
Posted (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_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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...