开发者

Issuing MySQL queries from standalone Javascript (no, I'm not crazy, my vendor is)

开发者 https://www.devze.com 2023-04-11 23:13 出处:网络
Our lab recently got an Agilent Bravo pipetting robot (it precisely dispenses tiny quantities of liquid for doing rapidly doing many biology or chemistry experiments). Apparently the glue language for

Our lab recently got an Agilent Bravo pipetting robot (it precisely dispenses tiny quantities of liquid for doing rapidly doing many biology or chemistry experiments). Apparently the glue language for extending the software that controls the robot is Javascript! I know, right?

Anyway, for the robot to be useful, we have to be able to retrieve information about the samples it's handling but every example I can find for sending queries in Javascript depends on PHP and usually the assumption that the script is running in a web-browser.

Is there some way to wrap a command-line mysql or is there already some library or utility that does this? The OS we're running is Windows 7.


Wow,开发者_StackOverflow中文版 thanks for the quick and useful answers.

In addition, I found a platform-specific answer: http://www.velocity11.com/techdocs/helpsystem/vworks_ug/usingjavascriptinvworks.html

Long story short, VWorks (control software for Agilent's equipment) has a run() global function that does exactly that. But, the above answers are probably more useful to this site than my own is, because they are relevant to a broader range of problems, so thanks again.


"sending queries in Javascript depends on PHP" no it doesn't.

Just send retreive data(json) using ajax, I'd use http://api.jquery.com/jQuery.ajax/.


Yes, you can use ADO with Javascript on Windows to access various data sources. Search for "jscript ado" and you will get lots of information on this, e.g.:

// path to database
var DBpath="\\\\Server\\Path\\myDB.mdb"

// set up a few object constants
var adLockReadOnly=1
var adOpenForwardOnly=0
var adCmdText=1

// create and open a new connection (MSAccess)
var cnn=new ActiveXObject("ADODB.connection")
cnn.Provider = "Microsoft.Jet.OLEDB.4.0;Data Source=" + DBpath
try
    {
    cnn.open
    }
catch(err)
    {
    // could not open connection
    // view details in err.Description and err.Number
    return 0
    }

//open a read only recordset
var rs = new ActiveXObject("ADODB.Recordset")
try
    {
    rs.Open("Select * from myTable", cnn, adOpenForwardOnly, adLockReadOnly)
    }
catch(err)
    {
    // could not open recordset
    return 0
    }
while(!rs.EOF)
    {
    // do something
    rs.movenext
    }
rs.close

Update:

According to info here, you can develop plugins using Visual Studio/C#. Maybe that is of some use? You could write a plugin to send the data somewhere...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号