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

Feature Request: mysql>=5.6 compatibility #105

Closed GD-stereschenkov closed 6 years ago

GD-stereschenkov commented 6 years ago

For type datetime with fps: lib/mysql_reader.py:


>             elif data_type.startswith('datetime('):
>                 return 'datetime'```
kworr commented 6 years ago

Can you post a patch or SQL code sample that will make the error manifest?

GD-stereschenkov commented 6 years ago

+--------------------+---------------+------+-----+---------+-------+
| Field              | Type          | Null | Key | Default | Extra |
+--------------------+---------------+------+-----+---------+-------+
| dag_id             | varchar(250)  | NO   | PRI | NULL    |       |
| is_paused          | tinyint(1)    | YES  |     | NULL    |       |
| is_subdag          | tinyint(1)    | YES  |     | NULL    |       |
| is_active          | tinyint(1)    | YES  |     | NULL    |       |
| last_scheduler_run | datetime(6)   | YES  |     | NULL    |       |
| last_pickled       | datetime(6)   | YES  |     | NULL    |       |
| last_expired       | datetime(6)   | YES  |     | NULL    |       |
| scheduler_lock     | tinyint(1)    | YES  |     | NULL    |       |
| pickle_id          | int(11)       | YES  |     | NULL    |       |
| fileloc            | varchar(2000) | YES  |     | NULL    |       |
| owners             | varchar(2000) | YES  |     | NULL    |       |
+--------------------+---------------+------+-----+---------+-------+
11 rows in set (0.00 sec)```
I got this error, when I run migration ( only data ):
```Traceback (most recent call last):
  File "/opt/python-envs/py-mysql2pgsql/bin/py-mysql2pgsql", line 38, in <module>
    mysql2pgsql.Mysql2Pgsql(options).convert()
  File "/opt/python-envs/py-mysql2pgsql/lib/python2.7/site-packages/mysql2pgsql/mysql2pgsql.py", line 31, in convert
    Converter(reader, writer, self.file_options, self.run_options.verbose).convert()
  File "/opt/python-envs/py-mysql2pgsql/lib/python2.7/site-packages/mysql2pgsql/lib/converter.py", line 51, in convert
    self.writer.write_contents(table, self.reader)
  File "/opt/python-envs/py-mysql2pgsql/lib/python2.7/site-packages/mysql2pgsql/lib/__init__.py", line 90, in decorated_function
    return f(*args, **kwargs)
  File "/opt/python-envs/py-mysql2pgsql/lib/python2.7/site-packages/mysql2pgsql/lib/postgres_db_writer.py", line 193, in write_contents
    self.copy_from(f, '"%s"' % table.name, ['"%s"' % c['name'] for c in table.columns])
  File "/opt/python-envs/py-mysql2pgsql/lib/python2.7/site-packages/mysql2pgsql/lib/postgres_db_writer.py", line 115, in copy_from
    columns=columns
psycopg2.extensions.QueryCanceledError: COPY from stdin failed: error in .read() call: exceptions.Exception unknown datetime(6)
CONTEXT:  COPY dag, line 1```
kworr commented 6 years ago

I think the fix was merged at ef150040a84172c7278e25b5165dfec5328bf6e3, can you check current version?

GD-stereschenkov commented 6 years ago

It works, thanks!