Reputation: 48
I want to migrate my site from a First to a Second Generation Cloud SQL instance, this is the old config:
DATABASES['[DATABASE_NAME]'] = {
'ENGINE': 'google.appengine.ext.django.backends.rdbms',
'INSTANCE': '[PROJECT_ID]:[INSTANCE_ID_1stGEN]',
'NAME': '[DATABASE_NAME]',
'USER': [MY_USER],
'PASSWORD': [MY_PASSWORD],
}
This works fine, now I'm trying with this code:
DATABASES['[DATABASE_NAME]'] = {
'ENGINE': 'django.db.backends.mysql',
'HOST': '/cloudsql/[PROJECT_NAME]:[REGION]:[INSTANCE_ID]',
'NAME': '[DATABASE_NAME]',
'USER': [MY_USER],
'PASSWORD': [MY_PASSWORD]
}
And this code
DATABASES['[DATABASE_NAME]'] = { # 2da gen no funciono error COUNT_ROWS
'ENGINE': 'django.db.backends.mysql',
'HOST': '[PROJECT_ID]:[REGION]:[INSTANCE_ID]',
'NAME': '[DATABASE_NAME]',
'USER': [MY_USER],
'PASSWORD': [MY_PASSWORD]
}
And this is the error:
AttributeError at /
'module' object has no attribute 'FOUND_ROWS'
/base/alloc/tmpfs/dynamic_runtimes/python27g/79cfdbb680326abd/python27/python27_lib/versions/third_party/django-1.5/django/db/backends/mysql/base.py in _cursor
kwargs['client_flag'] = CLIENT.FOUND_ROWS
I need your help, please.
The Django version is 1.5 is very old
I found a error, the ENGINE is wrong, I replaced it with google.appengine.ext.django.backends.rdbms
:
DATABASES['[DATABASE_NAME]'] = {
'ENGINE': 'google.appengine.ext.django.backends.rdbms',
'HOST': '/cloudsql/[PROJECT_ID]:[REGION]:[INSTANCE_ID]',
'NAME': '[DATABASE_NAME]',
'USER': [MY_USER],
'PASSWORD': [MY_PASSWORD]
}
but it still fails, now it says that an INSTANCE key is needed, then I replace HOST by INSTANCE:
DATABASES['[DATABASE_NAME]'] = {
'ENGINE': 'google.appengine.ext.django.backends.rdbms',
'INSTANCE': '/cloudsql/[PROJECT_ID]:[REGION]:[INSTANCE_ID]',
'NAME': '[DATABASE_NAME]',
'USER': [MY_USER],
'PASSWORD': [MY_PASSWORD]
}
... nothing ...
DATABASES['[DATABASE_NAME]'] = {
'ENGINE': 'google.appengine.ext.django.backends.rdbms',
'INSTANCE': '[PROJECT_ID]:[REGION]:[INSTANCE_ID]',
'NAME': '[DATABASE_NAME]',
'USER': MY_USER,
'PASSWORD':MY_PASSWORD
}
trying this, and now another error:
InternalError at /
(0, u'Not authorized to access instance: [PROJECT_ID]:[REGION]:[INSTANCE_ID]')
/base/alloc/tmpfs/dynamic_runtimes/python27g/79cfdbb680326abd/python27/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py in MakeRequest
request.request_id = self._idempotent_request_id
response = self._MakeRetriableRequest(stub_method, request)
else:
response = self.MakeRequestImpl(stub_method, request)
if (hasattr(response, 'sql_exception') and
response.HasField('sql_exception')):
raise _ToDbApiException(response.sql_exception) ...
return response
def _MakeRetriableRequest(self, stub_method, request):
"""Makes a retriable request.
Adding SSL/TSL configuration:
DATABASES['[DATABASE_NAME]'] = {
'ENGINE': 'google.appengine.ext.django.backends.rdbms',
'INSTANCE': '[PROJECT_ID]:[REGION]:[INSTANCE_ID]',
'NAME': '[DATABASE_NAME]',
'USER': [MY_USER],
'PASSWORD': [MY_PASSWORD],
'OPTIONS': {'ssl': {
'key': '/servidor/[INSTANCE_ID]/client-key.pem',
'cert': '/servidor/[INSTANCE_ID]/client-cert.pem',
'ca': '/servidor/[INSTANCE_ID]/client-ca.pem',
}}
And I still get the same error.
The certificate is working, with MySQL Workbench there is no problem.
Upvotes: 1
Views: 101
Reputation: 3764
The rdbms library will not work with an upgraded Second Generation Cloud SQL instance as stated on the documentation. In order to connect to your Sencond Generation Cloud SQL instance to your App Engine Standard application please make sure that your service account has the correct permissions and use the Unix domain socket. All the relevant information can be found here.
Upvotes: 1