Multiple times we get requests in projects to generate reports from database. Below command will be helpful in exporting the MySQL query results directly into CSV (comma separated values) file mysql -h {hostname} -u {username} -p {database_name} -B -e “SELECT code AS ‘Coupon Codes’ FROM salesrule_coupon WHERE rule_id=112” | sed “s/\t/,/g” > /tmp/coupon_code_$(date +%F).csv Above […]
Tag: SQL
MS SQL with PHP
Below is the simple PHP (>= 7.0.0) script to connect with the MS SQL database Hope this is helpful.
MS SQL with Magento
Here is a way to connect mssql database using Magento’s inbuilt models. Hope this is helpful