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 Answer
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>')
3 Comments
Donnacha
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?
Vladimir
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.
Donnacha
Apologies my password was wrong, thanks a million for your help :)