Export PostgreSQL Table to csv via Command Line

This article is focusing on showing how to export a single table from PostgreSQL database server. Exporting PostgreSQL table in this context of article means copying records exist in that table. The destination of the record copying process is a csv file. The process of copying those records is done using a command executed in a command line.

Off course there are several things need to be done as a prerequisite or preparation before the command for exporting records in a single table from PostgreSQL Database server can be carried out. Below are those steps :

Continue reading “Export PostgreSQL Table to csv via Command Line”

Laravel AJAX Validation Request Example

This is an article based on the example of writing a web-based application powered by Laravel Framework. This is article presenting an example of submitting a form through AJAX request to perform a validation which is done by Laravel framework so that it can be checked before whether or not the data or information submitted is true or false. The data or information will be weighed whether it is true or false by using the judgement of Laravel framework.  So, an article written with the title of ‘Laravel AJAX Validation Request Example’ can be stated as the following scenario :

A blade view file template is made to display the input form which is going to be used by user. Every input will be validated before it can actually be saved. But in the context of this article, the process will be stop only when the data or information has already been declared as true by Laravel framework validation. The process of submitting the data or information will be done or executed from an AJAX Request.

Continue reading “Laravel AJAX Validation Request Example”

Laravel Error Message : 422 Unprocessable Entity

This is an article which is used to discuss about an error message generated by a web-based application which is powered on Laravel framework. That error message is “422 Unprocessable Entity.”. That error itself is mentioned in the Laravel Documention specifically in the Validation part. Below is the explanation given in Laravel Documentation page for the validation using an AJAX request which is sending a form’s input message :

AJAX Requests & Validation

In this example, we used a traditional form to send data to the application. However, many applications use AJAX requests. When using the validate method during an AJAX request, Laravel will not generate a redirect response. Instead, Laravel generates a JSON response containing all of the validation errors. This JSON response will be sent with a 422 HTTP status code.

The scenario which is triggered an error specified in the title of this article, “422 Unprocessable Entity” is acquired when a form input message is sent using an AJAX request. This request finally will be processed through a specific controller file which is already defined in the router file definition of a Laravel web-based application.

Continue reading “Laravel Error Message : 422 Unprocessable Entity”

Laravel Error Message : SQLSTATE[42S22]: Column not found: 1054 Unknown column

This article written to describe on how to resolve the error given or specified in the title as ‘Column not found: 1054 Unknown column’. It is connected with the web-app based application powered by Laravel framework. Below is the display of the error message :

QueryException in Connection.php line 761:
SQLSTATE[42S22]: Column not found: 1054 Unknown
column 'ip_internal' in 'field list' (SQL: insert into `server` (`type`, `sn`, `label`, `ip_internal`, `ip_public`, `ip_management`, `year`, `warranty`) values (x, x, x, x, x, x, x, x))

The error message is actually relates on the process of saving a record to a certain table and in the above error the name of that table is ‘server’. The error above is retrieved from a firebug additional plugin installed in Mozilla Firefox web browser.

Continue reading “Laravel Error Message : SQLSTATE[42S22]: Column not found: 1054 Unknown column”

Failed to dump MySQL Database /tmp file permission denied

In this article, the main point of the discussion is about solving the problem occurred. Actually the problem is concerning on the failure process of dumping a MySQL database file. There is a failure which is caused by the permission problem on creating the temporary file as the destination target of the file. Based on the log file generated named ‘mysqld.log located in /var/log, it can be clearly well-informed that the problem lies on the permission of the target of the dump file for creating or writing a temporary file fo dumping the database :

[root@hostname ~]# tail -f /var/log/mysqld.log
/usr/libexec/mysqld: Can't create/write to file '/tmp/ib8zunMA' (Errcode: 13)
170510 14:58:11  InnoDB: Error: unable to create temporary file; errno: 13
170510 14:58:11 [ERROR] Plugin 'InnoDB' init function returned error.
170510 14:58:11 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
170510 14:58:11 [ERROR] Unknown/unsupported storage engine: InnoDB
170510 14:58:11 [ERROR] Aborting

170510 14:58:11 [Note] /usr/libexec/mysqld: Shutdown complete

170510 14:58:11 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

The location of the dump file is actually depends on the parameter given when the dump process is executed. But on the above context, it is believed that before assembling the real database dump file, a temporary file is being generated for the sake of setting up the real MySQL database dump file. The file is located in /tmp which is normally u use to generate a temporary file. But based on the above output, generating a temporary file for dumping database is forbidden.

To solve the problem, the only logic way is by changing the default temporary folder used to generate temporary file in the database dumping process. To change that folder location,  in this context, in order to solve the problem, just try to edit the file which is used as a MySQL Database Configuration file. It is a file named my.cnf normally located in /etc. Below is the line which is added to specify temporary directory to generate temporary backup database as follows :

Continue reading “Failed to dump MySQL Database /tmp file permission denied”

Laravel Error Message : Undefined variable: variable_name

This article is an article where an error as stated in the title of this article happened. The title which is also describing the error message is ‘Undefined variable :’. Depends on the circumstance and the condition regarding the script executed, the error message can be attached with various variable name. So, in the title of this article, the error which is described as an error message is specified as ‘Undefined variable : variable_name’.

The variable_name can be anything depend on the error which is pointed out after executing script which is becoming the cause of the error.

Continue reading “Laravel Error Message : Undefined variable: variable_name”

return view vs return redirect in Laravel

This article will discuss on the usage of several feature owned in Laravel development. The feature is focus on using return view vs return redirect in laravel framework on developing web-based application. Somehow, based on several experiment or trial and error which it might be a true conclusion of maybe not below is how those two features on directing a process into a rendered page defined, below is the scenario on testing those two features :

There is a page for inserting a property containing data of information about server. This is made by using a CRUD (Create Update Delete)-type web-based application powering on Laravel framework. The minute on the process of inserting all the data or information required for a Server has successfully executed, it is obvious that the process need to be redirected to the list page of Server where it will be displayed in the top of the list the information about the last Server which has saved early.

Continue reading “return view vs return redirect in Laravel”