skip to navigation
skip to content

BaseXClient 8.4.4

A client API for BaseX

BaseX is a light-weight, high-performance and scalable XML Database engine and XPath/XQuery 3.1 Processor, which includes full support for the W3C Update and Full Text extensions. An interactive and user-friendly GUI frontend gives you great insight into your XML documents.

The Python Client provides access to the BaseX features from within python. This enables records to be read and written from/to BaseX. Full support for FLOWR is provided as well as DB admin features.


Creating a new database

# -*- coding: utf-8 -*-
# This example shows how new databases can be created.
#
# Documentation: http://docs.basex.org/wiki/Clients
#
# (C) BaseX Team 2005-12, BSD License

import BaseXClient

# create session
session = BaseXClient.Session('localhost', 1984, 'admin', 'admin')

try:
    # create new database
    session.create("database", "<x>Hello World!</x>")
    print(session.info())

    # run query on database
    print("\n" + session.execute("xquery doc('database')"))

    # drop database
    session.execute("drop db database")
    print(session.info())

finally:
    # close session
    if session:
        session.close()

Query Example

# -*- coding: utf-8 -*-
# This example shows how queries can be executed in an iterative manner.
# Iterative evaluation will be slower, as more server requests are performed.
#
# Documentation: http://docs.basex.org/wiki/Clients
#
# (C) BaseX Team 2005-12, BSD License

import BaseXClient

# create session
session = BaseXClient.Session('localhost', 1984, 'admin', 'admin')

try:
    # create query instance
    input = "for $i in 1 to 10 return <xml>Text { $i }</xml>"
    query = session.query(input)

    # loop through all results
    for typecode, item in query.iter():
        print("typecode=%d" % typecode)
        print("item=%s" % item)

    # close query object
    query.close()

finally:
    # close session
    if session:
        session.close()

Add Example

# -*- coding: utf-8 -*-
# This example shows how new databases can be created.
#
# Documentation: http://docs.basex.org/wiki/Clients
#
# (C) BaseX Team 2005-12, BSD License

import BaseXClient

# create session
session = BaseXClient.Session('localhost', 1984, 'admin', 'admin')

try:
    # create new database
    session.create("database", "<x>Hello World!</x>")
    print(session.info())

    # run query on database
    print("\n" + session.execute("xquery doc('database')"))

    # drop database
    session.execute("drop db database")
    print(session.info())

finally:
    # close session
    if session:
        session.close()

Query Bind Example

# -*- coding: utf-8 -*-
# This example shows how new databases can be created.
#
# Documentation: http://docs.basex.org/wiki/Clients
#
# (C) BaseX Team 2005-12, BSD License

import BaseXClient

# create session
session = BaseXClient.Session('localhost', 1984, 'admin', 'admin')

try:
    # create new database
    session.create("database", "<x>Hello World!</x>")
    print(session.info())

    # run query on database
    print("\n" + session.execute("xquery doc('database')"))

    # drop database
    session.execute("drop db database")
    print(session.info())

finally:
    # close session
    if session:
        session.close()
 
File Type Py Version Uploaded on Size
BaseXClient-8.4.4-py2.py3-none-any.whl (md5) Python Wheel py2.py3 2016-06-14 6KB
  • Author: Ben Greene
  • Maintainer: BaseX
  • Home Page: http://www.basex.org
  • Bug Tracker: https://github.com/BaseXdb/basex/issues
  • Download URL: http://www.basex.org
  • Keywords: basex xml client
  • License:
    Copyright (c) 2005-12 BaseX Team <info@basex.org>
    All rights reserved.
    
    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
    are met:
    
    1. Redistributions of source code must retain the above copyright
       notice, this list of conditions and the following disclaimer.
    
    2. Redistributions in binary form must reproduce the above copyright
       notice, this list of conditions and the following disclaimer in the
       documentation and/or other materials provided with the distribution.
    
    3. Neither the name of the copyright holders nor the names of its
       contributors may be used to endorse or promote products derived
       from this software without specific prior written permission.
    
    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
    ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  • Provides BaseXClient
  • Categories
  • Package Index Owner: bengreen
  • DOAP record: BaseXClient-8.4.4.xml