Ich habe versucht, die Cloud SQL API von Google App zu verwenden, um eine CSV-Datei in meine Cloud SQL-Datenbank zu importieren, gefolgt von this die Methode, die es tut:GAE - Google Cloud SQL API zeigt keine Fehler an, erstellt aber keine Tabelle
def upload_file(cls):
credentials = GoogleCredentials.get_application_default()
service = discovery.
build('sqladmin', 'v1beta4', credentials=credentials)
# * Project ID of the project that contains the instance.
project = 'apptest'
# * Cloud SQL instance ID. This does not include the project ID.
instance = 'test'
instances_import_request_body = {
"importContext": {
"kind": "sql#importContext",
"fileType": "csv",
"uri": "gs://mybucket/test1.csv",
"database": "test",
"csvImportOptions": {
"table": "lote_1",
"columns": [
"id",
"numbers"
]
}
}
}
request = service.instances().import_(project=project, instance=instance, body=instances_import_request_body)
response = request.execute()
print response
Antwort:
{
{u'user': u'[email protected]', u'selfLink': u'https://www.googleapis.com/sql/v1beta4/projects/apptest/operations/d64dc88e-2395-4833-933f-2e004b5f961a', u'operationType': u'IMPORT', u'targetLink': u'https://www.googleapis.com/sql/v1beta4/projects/apptest/instances/test', u'status': u'PENDING', u'importContext': {u'database': u'test', u'csvImportOptions': {u'columns': [u'id', u'numbers'], u'table': u'lote_1'}, u'uri': u'gs://extraaniversario2016/test1.csv', u'kind': u'sql#importContext'}, u'insertTime': u'2016-10-24T20:59:17.853Z', u'kind': u'sql#operation', u'targetProject': u'apptest', u'name': u'd64dc88e-2395-4833-933f-2e004b5f961a', u'targetId': u'test'}
}
Meine CSV-Datei:
id;numbers
1;5
12345654;10
43543543543;2
343546464;8
Ich stehe fest, weil ich nicht weiß, ob ich das Ergebnis holen kann, weil es "ANHÄNGT" ist, ich habe gegoogelt und verschiedene Dinge für mehrere Stunden ausprobiert, aber ich kann nicht herausfinden, was falsch ist.
Danke für Ihre Hilfe!