140408 16:36:12 [ERROR] Unknown/unsupported storage engine: InnoDB
140408 16:36:12 [ERROR] Aborting
$ sudo rm /var/lib/mysql/ib_logfile*
then it will be fixed.
#
MariaDB 10.0 CentOS repository list - created 2014-04-08 20:31 UTC
#
http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
#!/usr/bin/python import os CITUS_DB_EXECUTABLE = '/opt/citusdb/3.0/bin/psql ' HOST = 'master' PORT = 5432 DATABASE = 'postgres' TABLE_DEF = '(ColumnA VARCHAR(10), ColumnB INTEGER, ColumnC TEXT)' SOURCE_FOLDER = '/tmp/' def create_table(table_name): os.system( CITUS_DB_EXECUTABLE + ' -h ' + HOST + ' -p ' + str(PORT) + ' -d ' + DATABASE + ' -c \"CREATE TABLE ' + table_name + TABLE_DEF + ' \"' ) print 'created table:', table_name def load_to_table(table_name): os.system( CITUS_DB_EXECUTABLE + ' -h ' + HOST + ' -p ' + str(PORT) + ' -d ' + DATABASE + ' -c "\STAGE ' + table_name + ' FROM ' + SOURCE_FOLDER + table_name + '.csv' + ' (FORMAT CSV)"') print 'loaded table:', table_name def main(): all_table_names = [] with open ('/home/haifzhan/table_names.txt', 'r') as f: for line in f: table_name = line.strip() create_table(table_name) load_to_table(table_name) if __name__ == '__main__': main()
abc,1
cba,2
file2.txt1,abc,001 2,cba,002
4,haifzhan,003To get the common lines of those two files, execute this command:awk -F',' 'NR==FNR{a[$1, $2]++;next} (a[$2,$1])' file1.txt file2.txt > comm.txt
the output is written into comm.txt, you can see the output below contains 3 columns, that's because once common parts are found, it will output the info based upon the second input file that is file2.txt.
1,abc,001 2,cba,002
It gets the 1st column and 2nd column of file1.txt and 2nd column and 1st column of file2, and checks the equality of those fileds.file1.txt and file2.txt donot have to be sorted when execute the above commands.
>>> calendar.timegm((datetime.datetime.strptime("2013-08-23 10:00:00", '%Y-%m-%d %H:%M:%S')).utctimetuple()) 1377252000 >>> int(str(time.mktime(datetime.datetime.strptime("2013-08-23 10:00:00", '%Y-%m-%d %H:%M:%S').utctimetuple()) )[:-2]) 1377277200
Why?
The reason is calendar.timegm(t) takes a UTC time as input, and time.mktime(t) takes a local time as input! So simple methods, but it took me way way too long time to find out what exactly happens!
Here's the python script:
import sys import datetime import time import calendar #date format TIME_FORMAT = '%Y-%m-%d %H:%M:%S' #hours offset from UTC TIME_OFFSET_TO_UTC = 0 #Converts date time to Unix time def date_to_unix(date_time): delta = datetime.timedelta(0,0,0,0,0,TIME_OFFSET_TO_UTC,0) return calendar.timegm((datetime.datetime.strptime(date_time, TIME_FORMAT) - delta).utctimetuple())
date_to_unix("2014-02-28 16:24:00")
This python script is to show how to get Local time and UTC time, and how to convert Local time to UTC time and vice versa.
Two methods should attract more attention. time.mktime(t) and calendar.timegm(t).
time.mktime(t) pass local time as a input and calendar.timegm(t)'s t is UTC time. The below is from python doc.
Therefore, when I convert local time to UTC time, I used time.mktime(t), and when I convert UTC to local time, I used calendar.timegm().
There're tons of ways to convert local time and UTC, the below script is one of all choices.
time.mktime(t) This is the inverse function of localtime(). Its argument is the struct_time or full 9-tuple (since the dst flag is needed; use -1 as the dst flag if it is unknown) which expresses the time in local time, not UTC. It returns a floating point number, for compatibility with time(). If the input value cannot be represented as a valid time, either OverflowError or ValueError will be raised (which depends on whether the invalid value is caught by Python or the underlying C libraries). The earliest date for which it can generate a time is platform-dependent.calendar.timegm(tuple) An unrelated but handy function that takes a time tuple such as returned by the gmtime() function in the time module, and returns the corresponding Unix timestamp value, assuming an epoch of 1970, and the POSIX encoding. In fact, time.gmtime() and timegm() are each others’ inverse.
#!/usr/bin/python import calendar import datetime import time TIME_FORMAT = '%Y-%m-%d %H:%M:%S' #Gets local time in given format def get_current_local_time(): local = datetime.datetime.now() print "Local:", local.strftime(TIME_FORMAT) #Gets UTC time in given format def get_current_utc_time(): utc = datetime.datetime.utcnow() print "UTC:", utc.strftime(TIME_FORMAT) #Converts local time to UTC time def local_2_utc(): local = datetime.datetime.now().strftime(TIME_FORMAT) print "local_2_utc: before convert:", local timestamp = str(time.mktime(datetime.datetime.strptime(local, TIME_FORMAT).timetuple()) )[:-2] utc = datetime.datetime.utcfromtimestamp(int(timestamp)) print "local_2_utc: after convert:", utc #Converts UTC time to local time def utc_2_local(): utc = datetime.datetime.utcnow().strftime(TIME_FORMAT) print "utc_2_local: before convert:", utc timestamp = calendar.timegm((datetime.datetime.strptime( utc, TIME_FORMAT)).timetuple()) local = datetime.datetime.fromtimestamp(timestamp).strftime(TIME_FORMAT) print "utc_2_local: after convert:", local #Invokes methods get_current_local_time() get_current_utc_time() local_2_utc() utc_2_local()