Files
libreoffice/pyuno/demo/biblioaccess.py

37 lines
1.0 KiB
Python
Raw Normal View History

2011-05-07 20:35:03 +01:00
# -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2011-05-07 20:35:03 +01:00
import uno
from com.sun.star.sdb.CommandType import COMMAND
def main():
connectionString = "socket,host=localhost,port=2002"
2011-05-07 20:35:03 +01:00
url = "uno:" + connectionString + ";urp;StarOffice.ComponentContext"
localCtx = uno.getComponentContext()
localSmgr = localCtx.ServiceManager
resolver = localSmgr.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", localCtx)
2011-05-07 20:35:03 +01:00
ctx = resolver.resolve(url)
smgr = ctx.ServiceManager
2011-05-07 20:35:03 +01:00
rowset =smgr.createInstanceWithContext("com.sun.star.sdb.RowSet", ctx)
rowset.DataSourceName = "Bibliography"
rowset.CommandType = COMMAND
rowset.Command = "SELECT IDENTIFIER, AUTHOR FROM biblio"
rowset.execute();
2011-05-07 20:35:03 +01:00
print("Identifier\tAuthor")
2011-05-07 20:35:03 +01:00
id = rowset.findColumn("IDENTIFIER")
author = rowset.findColumn("AUTHOR")
while rowset.next():
2011-05-07 20:35:03 +01:00
print(rowset.getString(id) + "\t" + repr(rowset.getString(author)))
rowset.dispose();
main()
2011-05-07 20:35:03 +01:00
# vim:set shiftwidth=4 softtabstop=4 expandtab: