1import uno 2 3from com.sun.star.sdb.CommandType import COMMAND 4 5def main(): 6 7 connectionString = "socket,host=localhost,port=2002" 8 9 url = "uno:"+connectionString + ";urp;StarOffice.ComponentContext" 10 11 localCtx = uno.getComponentContext() 12 localSmgr = localCtx.ServiceManager 13 resolver = localSmgr.createInstanceWithContext( 14 "com.sun.star.bridge.UnoUrlResolver", localCtx) 15 ctx = resolver.resolve( url ) 16 smgr = ctx.ServiceManager 17 18 rowset =smgr.createInstanceWithContext( "com.sun.star.sdb.RowSet", ctx ) 19 rowset.DataSourceName = "Bibliography" 20 rowset.CommandType = COMMAND 21 rowset.Command = "SELECT IDENTIFIER, AUTHOR FROM biblio" 22 23 rowset.execute(); 24 25 print "Identifier\tAuthor" 26 27 id = rowset.findColumn( "IDENTIFIER" ) 28 author = rowset.findColumn( "AUTHOR" ) 29 while rowset.next(): 30 print rowset.getString( id ) + "\t" + repr( rowset.getString( author ) ) 31 32 33 rowset.dispose(); 34 35main() 36