sqlite3-to-mysql icon indicating copy to clipboard operation
sqlite3-to-mysql copied to clipboard

adding support for DATETIME epochs

Open rekliner opened this issue 2 years ago • 9 comments

sqlite3 supports datetime fields but they were being ignored. They might have 32bit or 64bit epoch numbers, which I've converted down to 32bit for mysql compatibility.

rekliner avatar Feb 03 '23 02:02 rekliner

Hi and thanks for the submission. ♥️

Looks like this doesn't work with Python 2.7, which this package still supports. Can you ensure that it works with both 2.7 and 3?

Also, would you mind adding some tests specific to this commit?

techouse avatar Feb 04 '23 11:02 techouse

yeah, looks like 2.7 uses the time library rather than datetime. I've refactored but I'm still wrapping my head around unit testing in python

rekliner avatar Feb 08 '23 20:02 rekliner

@rekliner any progress?

techouse avatar Mar 12 '23 21:03 techouse

@techouse Sorry, have had unexpected family obligations and spare time is nonexistant. I should have time again next month for personal projects if you want to leave the pull open, I won't be insulted if not. I did find your tool very helpful to get my data from sqlite to mysql since Nextjs stopped supporting easily switching between them. They surprised their dev community with that as it no longer made sense to quickly develop with a local sqlite file. I'd love to help others who fell into that trap but haven't had time to research how to replicate my pull for python 2.

rekliner avatar Apr 03 '23 17:04 rekliner

@rekliner Take all the time you need. We all do this for the love of the community 🥳

techouse avatar Apr 03 '23 17:04 techouse

@rekliner I have recently released v2.0.0 which is Python 3.7+ only and have merged it into your PR, however, there's a bug with your code:

sqlite3_to_mysql/sqlite_utils.py:50: in convert_epoch
    _intval = int(value)
E   ValueError: invalid literal for int() with base 10: b'2007-07-09 14:20:19.000000'
        value      = b'2007-07-09 14:20:19.000000'

https://github.com/techouse/sqlite3-to-mysql/actions/runs/5229946600/jobs/9443242359#step:8:6773

techouse avatar Jun 10 '23 12:06 techouse

It seems that an ISO string is being passed to the function. I added it as a way to process epoch time, which was what I was getting from my sqlite files for fields identifying as DATETIME. I'm wondering if its a difference in python or platform that it is getting the ISO string rather than a number. It may be as simply be being tested wrong. I'll try to find out soon. Sorry I haven't had much time for this but I haven't forgotten.

rekliner avatar Jun 22 '23 16:06 rekliner

No worries. :) At least now you won't have to worry about Python 2 anymore :)

techouse avatar Jun 22 '23 18:06 techouse

You might want to look at how I solved this in my other repo here https://github.com/techouse/sqlite3-to-mysql/issues/36

techouse avatar Jun 24 '23 13:06 techouse