1bd8ef897SAndrew Rist# ************************************************************* 2bd8ef897SAndrew Rist# 3bd8ef897SAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 4bd8ef897SAndrew Rist# or more contributor license agreements. See the NOTICE file 5bd8ef897SAndrew Rist# distributed with this work for additional information 6bd8ef897SAndrew Rist# regarding copyright ownership. The ASF licenses this file 7bd8ef897SAndrew Rist# to you under the Apache License, Version 2.0 (the 8bd8ef897SAndrew Rist# "License"); you may not use this file except in compliance 9bd8ef897SAndrew Rist# with the License. You may obtain a copy of the License at 10bd8ef897SAndrew Rist# 11bd8ef897SAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 12bd8ef897SAndrew Rist# 13bd8ef897SAndrew Rist# Unless required by applicable law or agreed to in writing, 14bd8ef897SAndrew Rist# software distributed under the License is distributed on an 15bd8ef897SAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16bd8ef897SAndrew Rist# KIND, either express or implied. See the License for the 17bd8ef897SAndrew Rist# specific language governing permissions and limitations 18bd8ef897SAndrew Rist# under the License. 19bd8ef897SAndrew Rist# 20bd8ef897SAndrew Rist# ************************************************************* 21bd8ef897SAndrew Rist 22cdf0e10cSrcweirimport uno 23cdf0e10cSrcweir 24cdf0e10cSrcweirfrom com.sun.star.sdb.CommandType import COMMAND 25cdf0e10cSrcweir 26cdf0e10cSrcweirdef main(): 27cdf0e10cSrcweir 28cdf0e10cSrcweir connectionString = "socket,host=localhost,port=2002" 29*d912c6c5SPedro Giffuni 30cdf0e10cSrcweir url = "uno:"+connectionString + ";urp;StarOffice.ComponentContext" 31*d912c6c5SPedro Giffuni 32cdf0e10cSrcweir localCtx = uno.getComponentContext() 33cdf0e10cSrcweir localSmgr = localCtx.ServiceManager 34cdf0e10cSrcweir resolver = localSmgr.createInstanceWithContext( 35cdf0e10cSrcweir "com.sun.star.bridge.UnoUrlResolver", localCtx) 36cdf0e10cSrcweir ctx = resolver.resolve( url ) 37cdf0e10cSrcweir smgr = ctx.ServiceManager 38cdf0e10cSrcweir 39cdf0e10cSrcweir rowset =smgr.createInstanceWithContext( "com.sun.star.sdb.RowSet", ctx ) 40cdf0e10cSrcweir rowset.DataSourceName = "Bibliography" 41cdf0e10cSrcweir rowset.CommandType = COMMAND 42cdf0e10cSrcweir rowset.Command = "SELECT IDENTIFIER, AUTHOR FROM biblio" 43cdf0e10cSrcweir 44cdf0e10cSrcweir rowset.execute(); 45cdf0e10cSrcweir 46*d912c6c5SPedro Giffuni print("Identifier\tAuthor") 47cdf0e10cSrcweir 48cdf0e10cSrcweir id = rowset.findColumn( "IDENTIFIER" ) 49cdf0e10cSrcweir author = rowset.findColumn( "AUTHOR" ) 50cdf0e10cSrcweir while rowset.next(): 51*d912c6c5SPedro Giffuni print(rowset.getString( id ) + "\t" + repr( rowset.getString( author ) )) 52cdf0e10cSrcweir 53cdf0e10cSrcweir 54cdf0e10cSrcweir rowset.dispose(); 55cdf0e10cSrcweir 56cdf0e10cSrcweirmain() 57