Donnacha
Donnacha

Reputation: 79

Pythonanywhere MySQL connection

I'm new to pythonanywhere and am currently deploying my first app with it and the bottle framework. I have created a db with the online console but I don't know the syntax for accessing it. Is it the same syntax as when deploying locally? Or is it something else? MySQLdb has been imported... Thanks for any help.

Upvotes: 1

Views: 3293

Answers (1)

Vladimir
Vladimir

Reputation: 10493

Here is page on using MySQL at PythonAnywhere. It suggests to use the following configuration for django:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '<your_username>$<your_database_name>',
        'USER': '<your_username>',
        'PASSWORD': '<your_mysql_password>',
        'HOST': 'mysql.server',
    }
}

And I'm almost entirely sure that these credentials will be acceped by MySQLdb driver:

db=MySQLdb.connect(
    host='mysql.server',
    user='<your_username>',
    passwd='<your_mysql_password>',
    db='<your_username>$<your_database_name>')

Upvotes: 3

Related Questions