Skip to content

Question - INSERT INTO or CREATE TABLE from Node to 4D #10

@johanmorenolds

Description

@johanmorenolds

Hi Everybody, has anyone by any chance an example of how to create table and record records?

i have been trying to do it, but the problem that i am having right now is that it stays in a loop and never releases the sql connection. but the records and tables are created in 4D, the problem is that to terminate the process, and the connection i have to kill the node process.

this is a snippet of my code in case that you can see a problem with it

app.get('/addtodb',(req,res) => {
connection.connect( function( error ) {
if( error ) {
console.log( "Cannot connect to database: " + error );
return;
} else {
let sql = "INSERT INTO node4d (ID, Name) VALUES (1, 'Yohan')";
let query = connection.query( sql, (error,result) =>{// this is the point
if( error ) {
console.log( "Failed to run query: " + error );
return;
} else {
console.log( "post table created");
res.send('post table created');

            }
        } );
    }
} );

});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions