1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 <2016> 2017 2018 2019 2020 2021 2022 2023 2024 | Index | 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 <2016> 2017 2018 2019 2020 2021 2022 2023 2024 |
<== Date ==> | <== Thread ==> |
---|
Subject: | 答复: Question about "import MySQLdb" module problem in CSS python script |
From: | lzf neu <[email protected]> |
To: | "Kasemir, Kay" <[email protected]>, "[email protected]" <[email protected]> |
Date: | Sun, 18 Sep 2016 16:46:28 +0000 |
Hi Kay,
Thanks for your reply. I am new in CSS and now learning it. Actually, my problem needs to calculate the average, min and max value in an arbitrarily given period of time of record from mysql. I have to let the program know year, month, date, and hour etc. and this need to be filled in by the user in CSS boy text widget. Just as learning and regardless the speed of database operation, could you please give me some clue on how to use RDBUtil to access mysql and operate the database. Zhefu 发件人: Kasemir, Kay <[email protected]>
发送时间: 2016年9月18日 15:00 收件人: lzf neu 抄送: [email protected] 主题: Re: Question about "import MySQLdb" module problem in CSS python script Hi:
CSS BOY scripts are executed in jython, not python.
Most of the default python modules are also available in jython, but when you install python modules with binary dependencies like numpy, MySQL_python, .. those are not available in jython.
In jython you can instead call all the Java modules included in CS-Studio, for example the RDBUtil which allows access to Oracle, Postgres, MySQL.
But you shouldn’t really do that in a BOY script, because it’ll execute on the UI thread. Database operations are too slow, they will cause your complete UI to freeze.
The display tool was meant to display PVs, not to perform database operations.
If you do enjoy writing python code that interacts with MySQL, just do that outside of the display tool, then add a pcaspy CA server to provide the results as PVs, and display those PVs in CSS BOY.
-Kay
|