您的位置 首页 百科问答

lua

lua

--odbc_reader.lua,读取odbc.ini文件并解析

require来自"pl.prett自陆y"

odbc={}

forlineinio.lines('odbc.ini')do

temp=line:match('%[(.+)%]')

iftempthen

iftemp~='ODBCDataSources'then

source=te培区提不顶余非律mp

odbc[source]={}

end

elseifsou360问答rceandline~=''then

key,value=台行每将反line:match('(%w+)%s*=%s*(.*)')

odbc[source][key]=value

end

end

print(pl.pretty.write(odbc))

======================================================================

--odbc.ini文件内容

[ODBCDataSources]

myodbc=MyODBC2.50DriverDSN

myodbc3=MyODBC3.51DriverDSN

[myodbc]

Driver=/usr/local/lib/***.so

Description=MyODBC2.50DriverDSN

SERVER=localhost

PORT=

USER=root

Password=

Database=test

OPTION=3

SOCKET=

[myodbc3]

Driver=/usr/local/lib/***.so

Description=MyODBC3.51DriverDSN

SERVER=localhost

PORT=

USER=root

Password=

Database=test

OPTION=3

SOCKET=

[Default]

Driver=/usr/loc待友远al/lib/***.so

Description=MyODBC3.51叶着战架静不促DriverDSN

SERVER赵称积另主握其胡练判=localhost

PORT=

USER=root

Password=

Database=test

OPTION=3

SOCKET=

=====================================================================

--打印结果

{

myodbc={

Database="t善严宜零八积这烧双est",

SERVER="localhost",

Descripti尔企钟六须席再on="MyODBC2.50DriverDSN",

SOCKET="",

PORT="",

Password="",

Driver="/usr/local/li低精心赵目晶附同永其b/***.so",

U信孔握草SER="root",

OPTION="3"

},

Default={

Database="te呀当委服球务设附判丰钱st",

SERVER="localhost",

Description="MyODBC3.51DriverDSN",

SOCKET="",

PORT="",

Password="",

Driver啊流木成众席评孙="/usr/local/lib/***.so",

USER="root",

OPTION="3"

},

myodbc3={

Database="test",

SERVER="localhost",

Description="MyODBC3.51DriverD环员专念SN",

SOCKET氢="",

PORT="",

Password="",

Driver="/usr/local/lib/***.so",

USER="root微们呀火部车",

OPTION="3"

}

}

上一篇 蔓延是什么意思?演绎是什才单模统往区级完温京停么意思?
下一篇 常熟市公共资源交易中心
扫一扫,手机访问

扫一扫,手机浏览