Posts

Showing posts from December, 2012

Import data from mysql to mongo

To import data from mysql into mongodb we need to export data from mysql in a format mongo likes, this is either a tsv or a csv. Ideally you would like to use the following sql select columns INTO OUTFILE '/path/to/csv'    FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'    LINES TERMINATED BY '\n' from table [where clause] What the above SQL does is exports the data (only data , no headers) into a file as provided in your path, make sure you have access to location where you are putting the file. If you ignore the path and just use the filename this will be stored in the location where mysql data files are stored. To get the fields in the data file, we can use the following     echo "SELECT * FROM ;" | mysql -uXXX -pXXX > '/path/to/ .tsv' Finally you want all the be imported into a mongo database, here since our file contains a header we specify the --headerline option. For a complete list of

Use feeds module to import XML data in Drupal 7

Recently i had to setup a xml import process to import data from an external supplier on a regular basis, the filename and format was not changing and i could choose where to store the file. Following is how i set it up. First we need to download the following modules feeds feeds admin ui feeds_xpathparser ctools job_scheduler enable the above modules. We will need a sample XML so this will be the one we will use for this demonstration: <?xml version="1.0" encoding="utf-8" ?> <!-- Sample for demonstration of processing XML feeds with feeds module --> <Orders> <Order> <CustomerID>10</CustomerID> <Order_Number>1</Order_Number> <Order_Total>100</Order_Total> <Currency>£</Currency> </Order> <Order> <CustomerID>11</CustomerID> <Order_Number>2</Order_Number> <Order_Total>40</Order_Total> <Currency>$</Currency> <

Would you love apt-get on a mac?

As Ubuntu kept maturing i kept on gradually liking the "apt-get install" command in ubuntu to the point this felt like a hinderance on other linux flavours more notably Mac. To my surprise there is a tool available to make apt-get work in mac, this is fink (http://www.finkproject.org).  The binary is available to download for 10.5 and lower, for the rest who have moved on it seems the only option is to compile and install from source as per the instructions on the fink website. I had 10.8 (Mountain Lion) installed and as the fink site suggests i had to compile using source, before i could install fink i had to install xcode and xcode developer tools (xcode > preferences > downloads > developer tools) xcode-select -switch /path/to/Xcode.app/Contents/Developer I had to accept a license for Xcode build by reading and typing 'accept' sudo xcodebuild -license Unpack tar.gz manually or double click in your browsers download, if you want to ma