1

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.

1
  • Have you tried anything? Reading help for PythonAnywhere and for MySQLdb package is strongly recommended. Commented Sep 9, 2014 at 10:52

1 Answer 1

3

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>')
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks VLadimir, I had some similar to that, but when I use db_mysqlconnect(host='mysql.server', user='<your_username>', passwd='<your_mysql_password>', db='<your_username>$<your_database_name>') I get an error "undefined name '_mysql'", any thoughts?
From documentation on MySQL: If you want to write applications which are portable across databases, use MySQLdb, and avoid using this module directly. Code fixed.
Apologies my password was wrong, thanks a million for your help :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.