Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Allows access to local Postgres server without password #87

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions mysql2pgsql/lib/postgres_db_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -151,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):
Expand Down