From 8e804ac10f0ff295b439aa060bf79d34ae356cd4 Mon Sep 17 00:00:00 2001 From: pgcd Date: Sat, 16 May 2015 16:01:09 +0200 Subject: [PATCH 1/2] Allows access to local Postgres server without password This change allows the user to leave hostname empty to connect to a local server with no password. Also fixes an error in parsing empty passwords (that would become 'None' as string). --- mysql2pgsql/lib/postgres_db_writer.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mysql2pgsql/lib/postgres_db_writer.py b/mysql2pgsql/lib/postgres_db_writer.py index 2a67c15..eadb72d 100644 --- a/mysql2pgsql/lib/postgres_db_writer.py +++ b/mysql2pgsql/lib/postgres_db_writer.py @@ -72,12 +72,14 @@ def __init__(self, db_options, verbose=False, *args, **kwargs): super(PostgresDbWriter, self).__init__(*args, **kwargs) self.verbose = verbose self.db_options = { - 'host': str(db_options['hostname']), - 'port': db_options.get('port', 5432), 'database': str(db_options['database']), - 'password': str(db_options.get('password', None)) or '', + 'password': str(db_options.get('password', None) or ''), 'user': str(db_options['username']), } + if db_options.get('hostname'): + self.db_options['host'] = db_options.get('hostname') + self.db_options['port'] = db_options.get('port', 5432) + if ':' in str(db_options['database']): self.db_options['database'], self.schema = self.db_options['database'].split(':') else: From c5066ae85b89147f9665d96929247b66754507e1 Mon Sep 17 00:00:00 2001 From: pgcd Date: Sat, 13 Jun 2015 11:09:54 +0200 Subject: [PATCH 2/2] Update postgres_db_writer.py --- mysql2pgsql/lib/postgres_db_writer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql2pgsql/lib/postgres_db_writer.py b/mysql2pgsql/lib/postgres_db_writer.py index eadb72d..9ade879 100644 --- a/mysql2pgsql/lib/postgres_db_writer.py +++ b/mysql2pgsql/lib/postgres_db_writer.py @@ -153,7 +153,8 @@ def write_table(self, table): """ table_sql, serial_key_sql = super(PostgresDbWriter, self).write_table(table) for sql in serial_key_sql + table_sql: - self.execute(sql) + if sql != "": + self.execute(sql) @status_logger def write_indexes(self, table):