Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / pyuno / demo / biblioaccess.py
blob0e5d0b4c8071731a35e95df0ad65bef263906d70
1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 import uno
21 from com.sun.star.sdb.CommandType import COMMAND
23 def main():
24 connectionString = "socket,host=localhost,port=2002"
26 url = "uno:" + connectionString + ";urp;StarOffice.ComponentContext"
28 localCtx = uno.getComponentContext()
29 localSmgr = localCtx.ServiceManager
30 resolver = localSmgr.createInstanceWithContext(
31 "com.sun.star.bridge.UnoUrlResolver", localCtx)
32 ctx = resolver.resolve(url)
33 smgr = ctx.ServiceManager
35 rowset =smgr.createInstanceWithContext("com.sun.star.sdb.RowSet", ctx)
36 rowset.DataSourceName = "Bibliography"
37 rowset.CommandType = COMMAND
38 rowset.Command = "SELECT IDENTIFIER, AUTHOR FROM biblio"
40 rowset.execute();
42 print("Identifier\tAuthor")
44 id = rowset.findColumn("IDENTIFIER")
45 author = rowset.findColumn("AUTHOR")
46 while rowset.next():
47 print(rowset.getString(id) + "\t" + repr(rowset.getString(author)))
49 rowset.dispose();
51 main()
53 # vim: set shiftwidth=4 softtabstop=4 expandtab: