diff --git a/frappe/data_migration/doctype/data_migration_connector/connectors/postgres.py b/frappe/data_migration/doctype/data_migration_connector/connectors/postgres.py deleted file mode 100644 index 9c3e2af64d..0000000000 --- a/frappe/data_migration/doctype/data_migration_connector/connectors/postgres.py +++ /dev/null @@ -1,43 +0,0 @@ -from __future__ import unicode_literals -import frappe, psycopg2 -from .base import BaseConnection - -class PostGresConnection(BaseConnection): - def __init__(self, properties): - self.__dict__.update(properties) - self._connector = psycopg2.connect("host='{0}' dbname='{1}' user='{2}' password='{3}'".format(self.hostname, - self.database_name, self.username, self.password)) - self.cursor = self._connector.cursor() - - def get_objects(self, object_type, condition, selection): - if not condition: - condition = '' - else: - condition = ' WHERE ' + condition - self.cursor.execute('SELECT {0} FROM {1}{2}'.format(selection, object_type, condition)) - raw_data = self.cursor.fetchall() - data = [] - for r in raw_data: - row_dict = frappe._dict({}) - for i, value in enumerate(r): - row_dict[self.cursor.description[i][0]] = value - data.append(row_dict) - - return data - - def get_join_objects(self, object_type, field, primary_key): - """ - field.formula 's first line will be list of tables that needs to be linked to fetch an item - The subsequent lines that follows will contain one to one mapping across tables keys - """ - condition = "" - key_mapping = field.formula.split('\n') - obj_type = key_mapping[0] - selection = field.source_fieldname - - for d in key_mapping[1:]: - condition += d + ' AND ' - - condition += str(object_type) + ".id=" + str(primary_key) - - return self.get_objects(obj_type, condition, selection) diff --git a/frappe/data_migration/doctype/data_migration_connector/data_migration_connector.json b/frappe/data_migration/doctype/data_migration_connector/data_migration_connector.json index e4aca6763d..338d59aadd 100644 --- a/frappe/data_migration/doctype/data_migration_connector/data_migration_connector.json +++ b/frappe/data_migration/doctype/data_migration_connector/data_migration_connector.json @@ -62,7 +62,7 @@ "label": "Connector Type", "length": 0, "no_copy": 0, - "options": "\nFrappe\nPostgres\nCustom", + "options": "\nFrappe\nCustom", "permlevel": 0, "precision": "", "print_hide": 0, @@ -268,7 +268,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-10-26 12:03:40.646348", + "modified": "2017-12-01 13:38:55.992499", "modified_by": "Administrator", "module": "Data Migration", "name": "Data Migration Connector", diff --git a/frappe/data_migration/doctype/data_migration_connector/data_migration_connector.py b/frappe/data_migration/doctype/data_migration_connector/data_migration_connector.py index 5c597ee689..793dfe6694 100644 --- a/frappe/data_migration/doctype/data_migration_connector/data_migration_connector.py +++ b/frappe/data_migration/doctype/data_migration_connector/data_migration_connector.py @@ -8,7 +8,6 @@ from frappe.model.document import Document from frappe import _ from frappe.modules.export_file import create_init_py from .connectors.base import BaseConnection -from .connectors.postgres import PostGresConnection from .connectors.frappe_connection import FrappeConnection class DataMigrationConnector(Document): @@ -27,10 +26,7 @@ class DataMigrationConnector(Document): _class = get_connection_class(self.python_module) return _class(self) else: - if self.connector_type == 'Frappe': - self.connection = FrappeConnection(self) - elif self.connector_type == 'PostGres': - self.connection = PostGresConnection(self.as_dict()) + self.connection = FrappeConnection(self) return self.connection