mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-08 07:16:58 +02:00
24 lines
632 B
Python
24 lines
632 B
Python
# Author: Dimitri Fontaine <dim@tapoueh.org>
|
|
#
|
|
# pgloader mysql reformating module
|
|
#
|
|
|
|
def timestamp(reject, input):
|
|
""" Reformat str as a PostgreSQL timestamp
|
|
|
|
MySQL timestamps are like: 20041002152952
|
|
We want instead this input: 2004-10-02 15:29:52
|
|
"""
|
|
if len(input) != 14:
|
|
e = "MySQL timestamp reformat input too short: %s" % input
|
|
reject.log(e, input)
|
|
|
|
year = input[0:4]
|
|
month = input[4:6]
|
|
day = input[6:8]
|
|
hour = input[8:10]
|
|
minute = input[10:12]
|
|
seconds = input[12:14]
|
|
|
|
return '%s-%s-%s %s:%s:%s' % (year, month, day, hour, minute, seconds)
|