Copy link to clipboard
Copied
Hi,
I need to connect the postgresql database server via extendscript javascript. So I tried with the following code. But error thrown like 'require is not a function'. So please suggests if any ideas.
var pg= require('pg');
var connection = pg.createConnection({
host: '', port: '', user: 'test',
password : 'test', database : 'test'
});
connection.connect();
var queryString = "SELECT * FROM 'ExtendScriptTest'";
connection.end();
Thanks,
Latha
I need to connect the postgresql database server via extendscript javascript. So I tried with the following code. But error thrown like 'require is not a function'. So please suggests if any ideas.
Copy link to clipboard
Copied
Hello Latha,
This is not going to work, as you are using javascript that normally runs in a browser, and ExtendScript is running in the FrameMaker environment, which is definitely not a browser. You need to connect to a server that can retrieve dara and pass it to your script. The socket object is supported in ExtendScript and allows low-level communication to a server. I have used this in the past to connect FrameMaker to an SQL database via a PHP script running on a local server.
I cannot share my code here as it took quite some time to make it work and I do need to make a living out of the programming that I do. If you cannot figure it out with the info above, you can of course contact me direct (jang at jang dot nl) to give you a quote.
Kind regards from Amsterdam
4everJang
Copy link to clipboard
Copied
Hi,
as Jang mentioned it's not possible by ExtendScript.
For such use cases I develop an FDK plugin, perhaps with DotNet Integration, to make data access more easy than with c++.
Bye
Markus
Copy link to clipboard
Copied
Hi Markus,
I did not mention that it is impossible with ExtendScript, but it is not possible with the pg object. I made it work using a socket.
Kind regards
Copy link to clipboard
Copied
Hi Jang,
> to connect FrameMaker to an SQL database via a PHP script running on a local server.
This is not a direct connect, right?
So it's not possible query a database directly. If you want to connect with a database driver you have to go other ways.
Markus
Copy link to clipboard
Copied
Hi Markus,
Yes, technically that is correct. However, the original question indicated that there is a postgress server already. Either way, the solution will not be free 🙂
Ciao