Commands to export MySQL database schema, database with data, selective tables, ignoring tables
Tag: Database
All content which have database connectivity
MySQL Table Size
Get MySQL table sizes using a query
SQL query results to CSV
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 […]
MS SQL with Magento
Here is a way to connect mssql database using Magento’s inbuilt models. Hope this is helpful
Get database connection details in Magento
I am writing here an important code snippet for getting the database connection details used in Magento
Get table prefix in Magento
Hello All, I am writing here an important code snippet for getting the table prefix (if any defined) in Magento.
Get Table Name in Magento
I am writing here a small but useful snippet of code, for getting the table name of any module (whose table name are defined in config file). This is very useful when using joins in query. Suppose my module is ‘vendor’.
Filters in Query in Magento
Hello All, When we are filtering data in Magento, time occurs when we want to fetch result after filters like Not equal, greater than, less than, etc. The addFieldToFilter method’s second parameter is used for this. It supports an alternate syntax where, instead of passing in a string, you pass in a single element Array. […]
Insert and Retrieve file with MySQL
Some of you might be knowing that there is a functionality in MySQL database for storing files and retrieving the same. This is mainly used when we need to reduce response time for retrieving and using files in our application. I am listing here the method for inserting image file in and retrieving image file […]
Get Database Prefix
I am listing an example for retrieving the Joomla database prefix.