philipsoutham / py-mysql2pgsql

Tool for migrating/converting from mysql to postgresql.
http://packages.python.org/py-mysql2pgsql/
MIT License
455 stars 169 forks source link

TypeError: argument of type 'NoneType' is not iterable #96

Open vinny-silveira opened 8 years ago

vinny-silveira commented 8 years ago

i have used this program few months ago and never happened it...

wuliwong commented 7 years ago

Traceback (most recent call last): File "/usr/local/bin/py-mysql2pgsql", line 38, in <module> mysql2pgsql.Mysql2Pgsql(options).convert() File "/usr/local/lib/python2.7/site-packages/mysql2pgsql/mysql2pgsql.py", line 31, in convert Converter(reader, writer, self.file_options, self.run_options.verbose).convert() File "/usr/local/lib/python2.7/site-packages/mysql2pgsql/lib/converter.py", line 31, in convert self.writer.write_table(table) File "/usr/local/lib/python2.7/site-packages/mysql2pgsql/lib/__init__.py", line 86, in decorated_function ret = f(*args, **kwargs) File "/usr/local/lib/python2.7/site-packages/mysql2pgsql/lib/postgres_db_writer.py", line 151, in write_table table_sql, serial_key_sql = super(PostgresDbWriter, self).write_table(table) File "/usr/local/lib/python2.7/site-packages/mysql2pgsql/lib/postgres_writer.py", line 177, in write_table primary_keys, serial_key, maxval, columns = self.table_attributes(table) File "/usr/local/lib/python2.7/site-packages/mysql2pgsql/lib/postgres_writer.py", line 153, in table_attributes columns.write(' %s,\n' % self.column_description(column)) File "/usr/local/lib/python2.7/site-packages/mysql2pgsql/lib/postgres_writer.py", line 18, in column_description return '"%s" %s' % (column['name'], self.column_type_info(column)) File "/usr/local/lib/python2.7/site-packages/mysql2pgsql/lib/postgres_writer.py", line 107, in column_type_info default, column_type = get_type(column) File "/usr/local/lib/python2.7/site-packages/mysql2pgsql/lib/postgres_writer.py", line 79, in get_type if "CURRENT_TIMESTAMP" in column['default']: TypeError: argument of type 'NoneType' is not iterable

Same error here on OS X Sierra. Python 2.7.10

jmreymond commented 7 years ago

same issue here with a fresh installation on ubuntu 16.04 and Python 2.7.12

Traceback (most recent call last):
  File "/home/ubuntu/.local/bin/py-mysql2pgsql", line 38, in <module>
    mysql2pgsql.Mysql2Pgsql(options).convert()
  File "/home/ubuntu/.local/lib/python2.7/site-packages/mysql2pgsql/mysql2pgsql.py", line 31, in convert
    Converter(reader, writer, self.file_options, self.run_options.verbose).convert()
  File "/home/ubuntu/.local/lib/python2.7/site-packages/mysql2pgsql/lib/converter.py", line 31, in convert
    self.writer.write_table(table)
  File "/home/ubuntu/.local/lib/python2.7/site-packages/mysql2pgsql/lib/__init__.py", line 90, in decorated_function
    return f(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python2.7/site-packages/mysql2pgsql/lib/postgres_db_writer.py", line 151, in write_table
    table_sql, serial_key_sql = super(PostgresDbWriter, self).write_table(table)
  File "/home/ubuntu/.local/lib/python2.7/site-packages/mysql2pgsql/lib/postgres_writer.py", line 177, in write_table
    primary_keys, serial_key, maxval, columns = self.table_attributes(table)
  File "/home/ubuntu/.local/lib/python2.7/site-packages/mysql2pgsql/lib/postgres_writer.py", line 153, in table_attributes
    columns.write('  %s,\n' % self.column_description(column))
  File "/home/ubuntu/.local/lib/python2.7/site-packages/mysql2pgsql/lib/postgres_writer.py", line 18, in column_description
    return '"%s" %s' % (column['name'], self.column_type_info(column))
  File "/home/ubuntu/.local/lib/python2.7/site-packages/mysql2pgsql/lib/postgres_writer.py", line 107, in column_type_info
    default, column_type = get_type(column)
  File "/home/ubuntu/.local/lib/python2.7/site-packages/mysql2pgsql/lib/postgres_writer.py", line 79, in get_type
    if "CURRENT_TIMESTAMP" in column['default']:
TypeError: argument of type 'NoneType' is not iterable
kworr commented 7 years ago

Please provide some MySQL schema example so I can understand what is going on.

confar commented 6 years ago

This happens if column with type "timestamp" doesn't have a default value. I can make a PR with this fix, just an "if" condition.

asaarashi commented 5 years ago

any progress?