techouse / sqlite3-to-mysql

Transfer data from SQLite to MySQL

Home Page:https://techouse.github.io/sqlite3-to-mysql/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can not correctly convert sqlite's CHAR(2500) type

DiamondMofeng opened this issue · comments

Describe the bug

(venv) PS C:\Users\Administrator\Desktop\backend> sqlite3mysql -f C:\Users\Administrator\Desktop\backend\gamedata\gamedata.db -d screeps -u Mofeng --mysql-password  foobar -E
2022-08-11 21:20:36 INFO     Truncating table room_info
2022-08-11 21:20:36 INFO     Transferring table room_info
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 77776/77776 [00:32<00:00, 2368.99it/s] 
2022-08-11 21:21:09 ERROR    MySQL failed creating table room_terrain: 1074 (42000): Column length too big for column 'terrain' (max = 255); use BLOB or TEXT instead 
1074 (42000): Column length too big for column 'terrain' (max = 255); use BLOB or TEXT instead
(venv) PS C:\Users\Administrator\Desktop\backend>

The type of column terrain is 'CHAR(2500)'.

Types in table room_terrain:

cid name type
0 id INTEGER
1 room TEXT
2 shard TEXT
3 terrain CHAR(2500)

I also tried to add options like --mysql-text-type MEDIUMTEXT --mysql-string-type TEXT , which does not help.

System Information

| software               | version                              |
|------------------------|--------------------------------------|
| sqlite3-to-mysql       | 1.4.15                               |
|                        |                                      |
| Operating System       | Windows 10                           |
| Python                 | CPython 3.10.6                       |
| MySQL                  | Server version: 8.0.30 MySQL Community Server |
| SQLite                 | 3.37.2                               |
|                        |                                      |
| click                  | 8.0.4                                |
| mysql-connector-python | 8.0.30                               |
| pytimeparse            | 1.1.8                                |
| simplejson             | 3.17.6                               |
| six                    | 1.16.0                               |
| tabulate               | 0.8.10                               |
| tqdm                   | 4.64.0                               |

Additional context
Add any other context about the problem here.

In case of errors please run the same command with --debug. This option is only available on v1.4.12 or greater.

(venv) PS C:\Users\Administrator\Desktop\backend> sqlite3mysql -f C:\Users\Administrator\Desktop\backend\gamedata\gamedata.db -d screeps -u Mofeng --mysql-password  foobar -E --debug
2022-08-11 21:37:50 INFO     Truncating table room_info 
2022-08-11 21:37:50 INFO     Transferring table room_info 
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 77776/77776 [00:29<00:00, 2612.82it/s] 
2022-08-11 21:38:20 ERROR    MySQL failed creating table room_terrain: 1074 (42000): Column length too big for column 'terrain' (max = 255); use BLOB or TEXT instead 
Traceback (most recent call last): 
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\Administrator\Desktop\backend\venv\Scripts\sqlite3mysql.exe\__main__.py", line 7, in <module>
  File "c:\users\administrator\desktop\backend\venv\lib\site-packages\click\core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\administrator\desktop\backend\venv\lib\site-packages\click\core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "c:\users\administrator\desktop\backend\venv\lib\site-packages\click\core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\administrator\desktop\backend\venv\lib\site-packages\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "c:\users\administrator\desktop\backend\venv\lib\site-packages\sqlite3_to_mysql\cli.py", line 204, in cli
    converter.transfer()
  File "c:\users\administrator\desktop\backend\venv\lib\site-packages\sqlite3_to_mysql\transporter.py", line 700, in transfer
    self._create_table(table["name"], transfer_rowid=transfer_rowid)
  File "c:\users\administrator\desktop\backend\venv\lib\site-packages\sqlite3_to_mysql\transporter.py", line 380, in _create_table
    self._mysql_cur.execute(sql)
  File "c:\users\administrator\desktop\backend\venv\lib\site-packages\mysql\connector\cursor.py", line 1242, in execute
    self._prepared = self._connection.cmd_stmt_prepare(operation)
  File "c:\users\administrator\desktop\backend\venv\lib\site-packages\mysql\connector\connection.py", line 1484, in cmd_stmt_prepare
    result = self._handle_binary_ok(packet)
  File "c:\users\administrator\desktop\backend\venv\lib\site-packages\mysql\connector\connection.py", line 1424, in _handle_binary_ok
    raise get_exception(packet)
mysql.connector.errors.ProgrammingError: 1074 (42000): Column length too big for column 'terrain' (max = 255); use BLOB or TEXT instead
(venv) PS C:\Users\Administrator\Desktop\backend>

Hahaha, please forgive my ignorance. Besides, you may add a warning for invalid types

Well, I was under the impression that that would have been handled by the incoming database, LOL.

And actually, the error message correctly informed you of the user error, so I'm not sure what more I could do here.