![]() ![]() ![]() Create Table Having a Primary Key Create Primary Key in New Table: Using the SHOW TABLES command to check whether a table is built or not. Now open terminal command and execute the following command: Var sql = "CREATE TABLE users (id INT, name VARCHAR(255), email VARCHAR(255))" Example For creating a table named "users".īuild a javascript file called users.js that has the following data in the folder example. When making the connection, you have to make sure that you define the database name. Ssl: Ĭonst conn = new mysql.createConnection(config) Ĭonsole.log("!!! Cannot connect !!! Error:") Ĭonn.query('DELETE FROM inventory WHERE name = ?', ,Įlse console.log('Deleted ' + results.affectedRows + ' row(s).The command Build TABLE is used to build a table in MySQL. The query() function is used to execute the SQL query against MySQL database. The connect() function is used to establish the connection to the server. ![]() The mysql.createConnection() method is used to interface with the MySQL server. Use the following code to connect and load the data by using CREATE TABLE and INSERT INTO SQL statements. On Windows, if the node application isn't in your environment variable path, you may need to use the full path to launch the node application, such as "C:\Program Files\nodejs\node.exe" createtable.js.To run the application, enter the node command followed by the file name, such as node createtable.js.Open the command prompt or bash shell, and then change directory into your project folder cd nodejsmysql.This will allow the application to connect securely to the database over SSL. In the ssl config option, replace the ca-cert filename with the path to this local file.Save the certificate file to your preferred location. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |