ODBC Plugin?

Share your custom plugins and applications to enhance Rainmeter.

ODBC Plugin?

May 17th, 2017, 8:58 am
Matth
   [44 posts]

Hi

I am very new to Rainmeter and am intrigued by the possibilities of such a neat tool. I have played around a bit and created my first skins fetching some stock quotes from Yahoo and updating them every few seconds. That seems to work more or less as intended, but needs certainly more tweaking.

While the Webparser is a nice tool (with limitations though as it seems), I was wondering if there is a way to access databases directly through some kind of plugin or via an ODBC connection. That would greatly enhance the reach to include more real time meters.
User avatar

Re: ODBC Plugin?

May 18th, 2017, 6:23 am
khanhas
   [13 posts]

Hi, I recently made a stock skin and also had Yahoo as data preference.
As I noticed. when I myself were using it, Webparser did a great job at update data in realtime.
I wonder what worked "less as intended" in your skin
And what is your other data sources that have more intensive data update that you have to need a plugin to keep up with it.

Re: ODBC Plugin?

May 19th, 2017, 4:34 am
Matth
   [44 posts]

Well, I only spent a few hours trying to figure out the whole thing yet. When I meant it's performing more or less it was more a reference to my inability yet.

I guess my biggest critic point is the lack of a do while loop for both creating the measures and meters. It's so cumbersome to have to list them all one by one even if they are all the same.

I also would like to add some colors, so that if changes are positive, the colors should be green, if they stock changes are negative, the values should be displayed in red. Haven't figured that out yet. I am also struggling with changing format in the Yahoo JSON. If a value is NULL, then the format for the parser is different and it fails. Little things (I guess) but for a beginner a bit of a challenge. And adding an additional stock symbol is not just adding a single value to the query, it means also to add the measures and the meters. That should somehow be possible to do with a loop adding new values as required by the underlying data.

Back to the topic. I really admire the possibility that Rainmeter could open to create really nice dashboards for corporate desktops. Displaying real time information coming from ERP Systems. Much like showing the HW infos, but displaying sales, finance values, dispatched items, etc, etc. It would be such a light weight tool with infinite possiblities. Displaying hardware infos like the CPU/GPU, disks, network traffic etc. are all just statistics, either shown in graphical or number format. So it is about displaying data.

That's what I am after. Data is mostly stored in databases. It would open it up to show anything. Of course, I can create a site pulling the data from the database and feed a JSON. But why not avoid the extra step and go directly to the database? Using a simple SQL Query you can feed exactly the data that you need and let the database do the big work crunching, summarizing the thousands of values.

I have for example a website where I have log information in the database. If I could display those directly, displaying real time use of the site, that would be cool. Again, I can feed a JSON, and then parse it. But I would prefer to go the direct path.
User avatar

Re: ODBC Plugin?

May 20th, 2017, 5:59 am
khanhas
   [13 posts]

1) While-Do creating Measure/Meter:
Here a very basic trick, you can always expand it further and more complexity.
First, you need to have a list of thing you want to add as your skin variables
Here I have 4 but the last one is empty:

Code: Select all

[Variables]
Stock1 = CSCO
Stock2 = YHOO
Stock3 = ^IXIC
Stock4 =

You also need to manually create a file that will contain all measures and meters you want to automatically created and include it in your skin too.
Here I name it "mm.inc" and put in skin @Resources folder:

Code: Select all

@include=#@#mm.inc

In Lua script, I call While-do to get variables that have value and use it to create Measure and Meter. I put this loop in Initialize() function so it can generate every time I Refresh skin. I also have to refresh the skin again to actually have those measures and meters in skin.

Code: Select all

function Initialize()
   local file = io.open(SKIN:GetVariable('@')..'mm.inc','w')
   m = 1
   while SKIN:GetVariable('Stock'..m) and SKIN:GetVariable('Stock'..m) ~= '' do
      file:write('[MeasureStock'..m..']\n')
      file:write('Measure=Plugin\n')
      file:write('Plugin=WebParser\n')
      file:write('URL=https://finance.yahoo.com/quote/#Stock'..m..'#\n')
      file:write('RegExp=<getthis> getthat (parsethis) (parsethat)\n')
      file:write('StringIndex=1\n')
      
      file:write('[MeterStock'..m..']\n')
      file:write('Meter=String\n')
      file:write('Text=#Stock'..m..'#\n')

      file:write('[ValueStock'..m..']\n')
      file:write('Meter=String\n')
      file:write('MeasureName=MeasureStock'..m..'\n')
      file:write('X=R\nY=r\n')
      m = m + 1
   end
   file:close()
end

If your skin have "Add" feature, you should consider rename the function and call that function every time you "add".

2)Text color by stock change
Stock change that is negative should have "-" before its value. And we use that as "flag" to trigger action changing color.

Code: Select all

[MeasurePercent]
Measure=Plugin
Plugin=WebParser
URL=[StockInfo]
StringIndex=5
IfMatch=\-
IfMatchAction=[!Setoption Delta FontColor "ff333a"][!UpdateMeter Delta]
IfNotMatchAction=[!Setoption Delta FontColor "009933"][!UpdateMeter Delta]


I am curious of how to use Yahoo JSON because Yahoo website has a lot of weird class and id and I had a trouble time figuring out regexp to get what I want. JSON could help me decrease number of measures I have right now for a simple stock skin. It would be wonderful if you can walk me through some steps.

Re: ODBC Plugin?

May 21st, 2017, 3:06 pm
Matth
   [44 posts]

I have never worked with Lua scripts yet, but that seems to work quite nicely it seems. So I assume, the measures and meter in the mm.inc file are listed just once, without any number, right?

Below is what I have done so far with the Yahoo Stocks using the JSON. How can I help you with that?

I also tried to include the color changing feature and it works just perfectly (after a short struggle to limit it to the first character).

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Variables]
Stocks=0005.HK,0293.HK,USDCHF=X,0715.HK,^HSI,UBSG.VX,CSGN.VX,BBD-B.TO
Quote=(?(?=.*"symbol").*"Change_PercentChange":(.*),.*"LastTradeWithTime":(.*),.*"Name":(.*),.*"Open":(.*),.*"PreviousClose":(.*),)
;Quote=(?(?=.*<quote symbol).*<Bid>(.*)</Bid>.*<LastTradePriceOnly>(.*)</LastTradePriceOnly>.*<Name>(.*)</Name>.*<ChangeinPercent>(.*)</ChangeinPercent>.*<Ask>(.*)</Ask>)
Sub='"':"","<b>":"","</b>":""

[MeasureSite]
Measure=Plugin
Plugin=WebParser
URL=https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22#Stocks#%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=
;URL=https://query.yahooapis.com/v1/public/yql?q=select%20symbol,Ask,Bid,LastTradePriceOnly,Name,ChangeinPercent%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22#Stocks#%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=
RegExp=(?siU)"created":"(.*)",.*#Quote##Quote##Quote##Quote##Quote##Quote##Quote##Quote#
;RegExp=(?siU)"yahoo:created="(.*)" yahoo.*#Quote##Quote##Quote##Quote#
UpdateRate=200
;Debug=2

;Site info
[MeasureSiteDate]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=1
DecodeCharacterReference=1

;Item 1 info
[MeasureItem1Change]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=2
Substitute=#Sub#
IfMatch=^\-
IfMatchAction=[!SetOption MeterItem1Change FontColor "FF333A"][!UpdateMeter MeterItem1Change]
IfNotMatchAction=[!SetOption MeterItem1Change FontColor "C1E4FF"][!UpdateMeter MeterItem1Change]
[MeasureItem1Last]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=3
Substitute=#Sub#
[MeasureItem1Name]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=4
Substitute=#Sub#
[MeasureItem1Open]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=5
Substitute=#Sub#
[MeasureItem1Close]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=6
Substitute=#Sub#

;Item 2 info
[MeasureItem2Change]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=7
Substitute=#Sub#
IfMatch=^\-
IfMatchAction=[!SetOption MeterItem2Change FontColor "FF333A"][!UpdateMeter MeterItem2Change]
IfNotMatchAction=[!SetOption MeterItem2Change FontColor "C1E4FF"][!UpdateMeter MeterItem2Change]
[MeasureItem2Last]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=8
Substitute=#Sub#
[MeasureItem2Name]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=9
Substitute=#Sub#
[MeasureItem2Open]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=10
Substitute=#Sub#
[MeasureItem2Close]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=11
Substitute=#Sub#

;Item 3 info
[MeasureItem3Change]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=12
Substitute=#Sub#
IfMatch=^\-
IfMatchAction=[!SetOption MeterItem3Change FontColor "FF333A"][!UpdateMeter MeterItem3Change]
IfNotMatchAction=[!SetOption MeterItem3Change FontColor "C1E4FF"][!UpdateMeter MeterItem3Change]
[MeasureItem3Last]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=13
Substitute=#Sub#
[MeasureItem3Name]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=14
Substitute=#Sub#
[MeasureItem3Open]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=15
Substitute=#Sub#
[MeasureItem3Close]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=16
Substitute=#Sub#

;Item 4 info
[MeasureItem4Change]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=17
Substitute=#Sub#
IfMatch=^\-
IfMatchAction=[!SetOption MeterItem4Change FontColor "FF333A"][!UpdateMeter MeterItem4Change]
IfNotMatchAction=[!SetOption MeterItem4Change FontColor "C1E4FF"][!UpdateMeter MeterItem4Change]
[MeasureItem4Last]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=18
Substitute=#Sub#
[MeasureItem4Name]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=19
Substitute=#Sub#
[MeasureItem4Open]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=20
Substitute=#Sub#
[MeasureItem4Close]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=21
Substitute=#Sub#

;Item 5 info
[MeasureItem5Change]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=22
Substitute=#Sub#
IfMatch=^\-
IfMatchAction=[!SetOption MeterItem5Change FontColor "FF333A"][!UpdateMeter MeterItem5Change]
IfNotMatchAction=[!SetOption MeterItem5Change FontColor "C1E4FF"][!UpdateMeter MeterItem5Change]
[MeasureItem5Last]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=23
Substitute=#Sub#
[MeasureItem5Name]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=24
Substitute=#Sub#
[MeasureItem5Open]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=25
Substitute=#Sub#
[MeasureItem5Close]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=26
Substitute=#Sub#

;Item 6 info
[MeasureItem6Change]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=27
Substitute=#Sub#
IfMatch=^\-
IfMatchAction=[!SetOption MeterItem6Change FontColor "FF333A"][!UpdateMeter MeterItem6Change]
IfNotMatchAction=[!SetOption MeterItem6Change FontColor "C1E4FF"][!UpdateMeter MeterItem6Change]
[MeasureItem6Last]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=28
Substitute=#Sub#
[MeasureItem6Name]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=29
Substitute=#Sub#
[MeasureItem6Open]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=30
Substitute=#Sub#
[MeasureItem6Close]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=31
Substitute=#Sub#

;Item 7 info
[MeasureItem7Change]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=32
Substitute=#Sub#
IfMatch=^\-
IfMatchAction=[!SetOption MeterItem7Change FontColor "FF333A"][!UpdateMeter MeterItem7Change]
IfNotMatchAction=[!SetOption MeterItem7Change FontColor "C1E4FF"][!UpdateMeter MeterItem7Change]
[MeasureItem7Last]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=33
Substitute=#Sub#
[MeasureItem7Name]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=34
Substitute=#Sub#
[MeasureItem7Open]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=35
Substitute=#Sub#
[MeasureItem7Close]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=36
Substitute=#Sub#

;Item 8 info
[MeasureItem8Change]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=37
Substitute=#Sub#
IfMatch=^\-
IfMatchAction=[!SetOption MeterItem8Change FontColor "FF333A"][!UpdateMeter MeterItem8Change]
IfNotMatchAction=[!SetOption MeterItem8Change FontColor "C1E4FF"][!UpdateMeter MeterItem8Change]
[MeasureItem8Last]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=38
Substitute=#Sub#
[MeasureItem8Name]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=39
Substitute=#Sub#
[MeasureItem8Open]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=40
Substitute=#Sub#
[MeasureItem8Close]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=41
Substitute=#Sub#

;MeterStyles
[HeaderStyle]
X=5
Y=25
W=290
H=40
FontFace=Segoe UI
FontSize=8
FontColor=84,186,255,255
StringStyle=Bold
StringAlign=Right
SolidColor=0,0,0,1
ClipString=1
AntiAlias=1
ToolTipWidth=300

[TextStyle]
X=5
Y=3R
W=290
H=20
FontFace=Segoe UI
FontSize=8
;FontColor=255,255,255,255
FontColor=193,228,255,255
StringAlign=Right
SolidColor=0,0,0,1
StringEffect=Border
FontEffectColor=0,148,255,128
ClipString=1
AntiAlias=1
ToolTipWidth=300

;Meters
[MeterBackground]
Meter=Image
W=450
H=165
SolidColor=0,0,0,255

[MeterSite]
Meter=String
MeasureName=MeasureSiteDate
MeterStyle=HeaderStyle
FontColor=226,245,184,255
StringStyle=Bold
StringAlign=Left
DynamicVariables=1
Y=3
X=5
W=290
H=20
[MeterItem0]
Meter=String
Text=Name
StringAlign=Left
MeterStyle=HeaderStyle
[MeterItem0Close]
Meter=String
Text=Close
MeterStyle=HeaderStyle
X=170
[MeterItem0Open]
Meter=String
Text=Open
MeterStyle=HeaderStyle
X=236
[MeterItem0Change]
Meter=String
Text=Change
MeterStyle=HeaderStyle
X=445
[MeterItem0Last]
Meter=String
Text=Last Trade
MeterStyle=HeaderStyle
X=345

[MeterItem1]
Meter=String
MeasureName=MeasureItem1Name
MeterStyle=TextStyle
StringAlign=Left
Y=40
DynamicVariables=1
ClipString=1
W=100
H=20
[MeterItem1Close]
Meter=String
MeasureName=MeasureItem1Close
MeterStyle=TextStyle
Y=40
X=170
[MeterItem1Change]
Meter=String
MeasureName=MeasureItem1Change
MeterStyle=TextStyle
Y=40
X=445
[MeterItem1Last]
Meter=String
MeasureName=MeasureItem1Last
MeterStyle=TextStyle
Y=40
X=345
[MeterItem1Open]
Meter=String
MeasureName=MeasureItem1Open
MeterStyle=TextStyle
IfBelowValue=0
IfBelowAction=FontColor=255,0,0,255
Y=40
X=236

[MeterItem2]
Meter=String
MeasureName=MeasureItem2Name
MeterStyle=TextStyle
StringAlign=Left
Y=55
DynamicVariables=1
ClipString=1
W=100
H=20
[MeterItem2Close]
Meter=String
MeasureName=MeasureItem2Close
MeterStyle=TextStyle
Y=55
X=170
[MeterItem2Change]
Meter=String
MeasureName=MeasureItem2Change
MeterStyle=TextStyle
Y=55
X=445
[MeterItem2Last]
Meter=String
MeasureName=MeasureItem2Last
MeterStyle=TextStyle
Y=55
X=345
[MeterItem2Open]
Meter=String
MeasureName=MeasureItem2Open
IfCondition=MeasureItem2Open<0
IfTrueAction=FontColor=255,0,0,255
MeterStyle=TextStyle
Y=55
X=236

[MeterItem3]
Meter=String
MeasureName=MeasureItem3Name
MeterStyle=TextStyle
StringAlign=Left
Y=70
DynamicVariables=1
ClipString=1
W=100
H=20
[MeterItem3Close]
Meter=String
MeasureName=MeasureItem3Close
MeterStyle=TextStyle
Y=70
X=170
[MeterItem3Change]
Meter=String
MeasureName=MeasureItem3Change
MeterStyle=TextStyle
Y=70
X=445
[MeterItem3Last]
Meter=String
MeasureName=MeasureItem3Last
MeterStyle=TextStyle
Y=70
X=345
[MeterItem3Open]
Meter=String
MeasureName=MeasureItem3Open
IfCondition=MeasureItem3Open<0
IfTrueAction=FontColor=255,0,0,255
MeterStyle=TextStyle
Y=70
X=236

[MeterItem4]
Meter=String
MeasureName=MeasureItem4Name
MeterStyle=TextStyle
StringAlign=Left
Y=85
DynamicVariables=1
ClipString=1
W=100
H=20
[MeterItem4Close]
Meter=String
MeasureName=MeasureItem4Close
MeterStyle=TextStyle
Y=85
X=170
[MeterItem4Change]
Meter=String
MeasureName=MeasureItem4Change
MeterStyle=TextStyle
Y=85
X=445
[MeterItem4Last]
Meter=String
MeasureName=MeasureItem4Last
MeterStyle=TextStyle
Y=85
X=345
[MeterItem4Open]
Meter=String
MeasureName=MeasureItem4Open
IfCondition=MeasureItem4Open<0
IfTrueAction=FontColor=255,0,0,255
MeterStyle=TextStyle
Y=85
X=236

[MeterItem5]
Meter=String
MeasureName=MeasureItem5Name
MeterStyle=TextStyle
StringAlign=Left
Y=100
DynamicVariables=1
ClipString=1
W=100
H=20
[MeterItem5Close]
Meter=String
MeasureName=MeasureItem5Close
MeterStyle=TextStyle
Y=100
X=170
[MeterItem5Change]
Meter=String
MeasureName=MeasureItem5Change
MeterStyle=TextStyle
Y=100
X=445
[MeterItem5Last]
Meter=String
MeasureName=MeasureItem5Last
MeterStyle=TextStyle
Y=100
X=345
[MeterItem5Open]
Meter=String
MeasureName=MeasureItem5Open
IfCondition=MeasureItem5Open<0
IfTrueAction=FontColor=255,0,0,255
MeterStyle=TextStyle
Y=100
X=236

[MeterItem6]
Meter=String
MeasureName=MeasureItem6Name
MeterStyle=TextStyle
StringAlign=Left
Y=115
DynamicVariables=1
ClipString=1
W=100
H=20
[MeterItem6Close]
Meter=String
MeasureName=MeasureItem6Close
MeterStyle=TextStyle
Y=115
X=170
[MeterItem6Change]
Meter=String
MeasureName=MeasureItem6Change
MeterStyle=TextStyle
Y=115
X=445
[MeterItem6Last]
Meter=String
MeasureName=MeasureItem6Last
MeterStyle=TextStyle
Y=115
X=345
[MeterItem6Open]
Meter=String
MeasureName=MeasureItem6Open
IfCondition=MeasureItem6Open<0
IfTrueAction=FontColor=255,0,0,255
MeterStyle=TextStyle
Y=115
X=236

[MeterItem7]
Meter=String
MeasureName=MeasureItem7Name
MeterStyle=TextStyle
StringAlign=Left
Y=130
DynamicVariables=1
ClipString=1
W=100
H=20
[MeterItem7Close]
Meter=String
MeasureName=MeasureItem7Close
MeterStyle=TextStyle
Y=130
X=170
[MeterItem7Change]
Meter=String
MeasureName=MeasureItem7Change
MeterStyle=TextStyle
Y=130
X=445
[MeterItem7Last]
Meter=String
MeasureName=MeasureItem7Last
MeterStyle=TextStyle
Y=130
X=345
[MeterItem7Open]
Meter=String
MeasureName=MeasureItem7Open
IfCondition=MeasureItem7Open<0
IfTrueAction=FontColor=255,0,0,255
MeterStyle=TextStyle
Y=130
X=236

[MeterItem8]
Meter=String
MeasureName=MeasureItem8Name
MeterStyle=TextStyle
StringAlign=Left
Y=145
DynamicVariables=1
ClipString=1
W=100
H=20
[MeterItem8Close]
Meter=String
MeasureName=MeasureItem8Close
MeterStyle=TextStyle
Y=145
X=170
[MeterItem8Change]
Meter=String
MeasureName=MeasureItem8Change
MeterStyle=TextStyle
Y=145
X=445
[MeterItem8Last]
Meter=String
MeasureName=MeasureItem8Last
MeterStyle=TextStyle
Y=145
X=345
[MeterItem8Open]
Meter=String
MeasureName=MeasureItem8Open
IfCondition=MeasureItem8Open<0
IfTrueAction=FontColor=255,0,0,255
MeterStyle=TextStyle
Y=145
X=236
User avatar

Re: ODBC Plugin?

May 22nd, 2017, 8:17 am
khanhas
   [13 posts]

JSON file have cut down my skin's work load alot. Here I just wrote a simple json parser in Lua. It will parse every data in each stock and put them in table. If you're interested in more efficient way than using alot of WebParser measures, you can put it in your skin:
Edit your skin ini:

Code: Select all

[MeasureSite]
Measure=Plugin
Plugin=WebParser
URL=https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22#Stocks#%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=
Download=1
DownloadFile=StockInfo.json
FinishAction=[!CommandMeasure "YourScriptMeasure" "doit()"]

[Name]
meter=string
FontSize=15
AntiAlias=1
FontColor=ffffff
Group=All

[Close]
meter=string
FontSize=15
AntiAlias=1
FontColor=ffffff
StringAlign=Right
X=200R
Group=All

[Open]
meter=string
MeterStyle=Close
X=200R

[Time]
meter=string
MeterStyle=Close
X=200R

[Change]
meter=string
MeterStyle=Close
X=200R


In Lua script add:

Code: Select all

function doit()
   local file = io.open(SKIN:GetVariable('ROOTCONFIGPATH')..'DownloadFile\\StockInfo.json','r')
   local content = file:read('*a')
   file:close()
   quotes = content:match('{"quote":%[(.*)%]}')
   stockTable={}
   for stock,data in quotes:gmatch('{"symbol":"(.-)",(.-)}') do
      stockTable[stock] = {}
      data = data .. ','
      --print('----------------'..stock..'------------------')
      for k,v in data:gmatch('"(.-)":"?(.-)"?,') do
         stockTable[stock][k] = v
         --print(k,stockTable[stock][k])
      end
   end
   names,close,opens,trade,delta = 'Name','Close','Open','Last Trade','Change'
   for n,_ in pairs(stockTable) do
      names = names .. '#CRLF#' .. stockTable[n]['Name']
      close = close .. '#CRLF#' .. stockTable[n]['PreviousClose']
      opens = opens .. '#CRLF#' .. stockTable[n]['Open']
      trade = trade .. '#CRLF#' .. stockTable[n]['LastTradeWithTime']
      delta = delta .. '#CRLF#' .. stockTable[n]['Change_PercentChange']
   end
   SKIN:Bang('!SetOption Name Text "'..names..'"')
   SKIN:Bang('!SetOption Close Text "'..close..'"')
   SKIN:Bang('!SetOption Open Text "'..opens..'"')
   SKIN:Bang('!SetOption Time Text "'..string.gsub(trade:gsub('<b>',''),'</b>','')..'"')
   SKIN:Bang('!SetOption Change Text "'..delta..'"')
   SKIN:Bang('[!UpdateMeterGroup All]')

You can remove "--" before print command to see what it has parsed in Log window.
User avatar

Re: ODBC Plugin?

May 23rd, 2017, 3:23 am
tjhrulz
   [28 posts]

Why would you want to access a database directly in rainmeter, I guess someone could make an ODBC plugin but that seems kinda silly. Are you trying to say you want to be able to run javascript on a page? If that is what you want I would look at using phantomJS using Rainmeter's RunCommand

Re: ODBC Plugin?

May 23rd, 2017, 10:11 am
Matth
   [44 posts]

No, I'm not looking at running JavaScript on the page.

With Rainmeter I can create all sorts of graphs and display ever changing information on my PC's desktop. Now from what I see in most skins, it is information about the actual PC. CPU, temperature, date and time, diskspace, etc. That is all nice and "cool", but it's just a gadget.

I would love to display more interesting information. Data coming directly from databases (which are really good at storing and delivering information). As I wrote, create a couple of selects to an ERP database, and you have a very nice dashboard showing "live" information about your company. Sales in your shop? There you have a graph. Number of hours worked/recorded by your staff? Watch it climbing up as the day passes. The top ten products of the day? List them on your desktop. Etc. etc., There are endless possibilities.

Yes, you can always go around a webserver and create a JSON and parse that one. But an ODBC access to get information directly from the database would be so much nicer.

Return to “Plugins & Addons”



Who is online

Users browsing this forum: No registered users and 3 guests