Jump to content


Photo

Daily Import into X2

How to staff response

  • Please log in to reply
3 replies to this topic

#1 LRSpartan

LRSpartan

    Advanced Member

  • Members
  • PipPipPip
  • 67 posts

Posted 03 April 2017 - 06:48 AM

Is there a way to schedule / automate a daily import of data into X2?

 

Thanks,

John



#2 X2Raymond

X2Raymond

    Advanced Member

  • Administrators
  • 972 posts
  • LocationSanta Cruz, CA

Posted 03 April 2017 - 01:53 PM

No, this is not currently possible within the UI, for example using X2Workflow. Currently to do what you're describing would require an external script and use of the API. If your data source supports remote API calls, this would be most convenient for your use case. Where is the daily import data coming from? Is it already in CSV format?



#3 LRSpartan

LRSpartan

    Advanced Member

  • Members
  • PipPipPip
  • 67 posts

Posted 19 May 2017 - 10:43 AM

Hey Raymond,

 

Sorry I missed your response to this.

 

The data is coming from our portfolio management system, Axys. I can get the data in CSV, and I was wanting to update the previous days values. The values would only be read-only once in X2. So no user can make changes. They can only see the values.

 

So Client ABC as of yesterday had $500K in their account and today they have $510K. I would have unique identifiers in place between x2 and Axys. I was going to see if MySQL has a import / update script and just schedule that into the X2 table.

 

I know the preference is to go through x2 for data entry but since it would be static user data, I would think this shouldn't be an issue with X2 if I did a MySQL import.

 

What do you think? Thanks for your insight!



#4 X2Raymond

X2Raymond

    Advanced Member

  • Administrators
  • 972 posts
  • LocationSanta Cruz, CA

Posted 19 May 2017 - 11:53 AM

Hi John,

 

Ah yes, you would be able to import into MySQL by leveraging the mysqlimport command. What you would want to do is set up a cron job to retrieve your CSV, then import it into MySQL. You'd want to schedule a script similar to the following, replacing user, password, and database with the appropriate values for your MySQL configuration:

#!/bin/sh
wget https://example.com/path/to/data.csv
mv data.csv x2_contacts.csv
mysqlimport --ignore-lines=1 --fields-terminated-by=, --local \
            -u user -p'password' database x2_contacts.csv
rm x2_contacts.csv

If your column order does not match that of the x2_contacts table, you can specify it as a comma-separated list with the --columns option.

 

We recently introduced the "import" Yii console command, but currently it is restricted to performing rollbacks (for large imports). In a future release, we can provide a CSV import functionality to the command, which would simplify the above process.

 

Raymond







Also tagged with one or more of these keywords: How to, staff response

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users