mardi 13 mai 2014

MySQL - se connecter à RDS de l'instance EC2 avec Python - Stack Overflow


Struggling with connecting to a database through python running on an RDS instance.


I've looked around at tutorials and I've tried this piece from amazon


DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mydb',
'USER': 'sa',
'PASSWORD': 'mypwd',
'HOST': 'mydbinstance.abcdefghijkl.us-east-1.rds.amazonaws.com',
'PORT': '3306',
}
}

obviously I've substituted in my own details, but I'm not sure where to go from there. It also seems to using something called Beanstalk, which unless is there automatically on all AWS instances, I don't have. All I want to do is write some details to a table. Is there a tutorial or some advice anyone can give me?




If you want to access the data in a raw python script, you will have to use a suitable mysql connector class for python, just passing the database details raw into the script won't help.


So, check out MySQLdb and mysql.connector then.


Also, do ensure that the RDS instance is iteslf accessible from the EC2 instance, and there is no permission/access discrepancy causing the issue.


mysql -usa -p -hmydbinstance.abcdefghijkl.us-east-1.rds.amazonaws.com mydb
#*sa* is the user in *-usa*


Struggling with connecting to a database through python running on an RDS instance.


I've looked around at tutorials and I've tried this piece from amazon


DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mydb',
'USER': 'sa',
'PASSWORD': 'mypwd',
'HOST': 'mydbinstance.abcdefghijkl.us-east-1.rds.amazonaws.com',
'PORT': '3306',
}
}

obviously I've substituted in my own details, but I'm not sure where to go from there. It also seems to using something called Beanstalk, which unless is there automatically on all AWS instances, I don't have. All I want to do is write some details to a table. Is there a tutorial or some advice anyone can give me?



If you want to access the data in a raw python script, you will have to use a suitable mysql connector class for python, just passing the database details raw into the script won't help.


So, check out MySQLdb and mysql.connector then.


Also, do ensure that the RDS instance is iteslf accessible from the EC2 instance, and there is no permission/access discrepancy causing the issue.


mysql -usa -p -hmydbinstance.abcdefghijkl.us-east-1.rds.amazonaws.com mydb
#*sa* is the user in *-usa*

0 commentaires:

Enregistrer un commentaire