BaseXClient-8.4.4
توضیحات
A client API for BaseX
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | BaseXClient-8.4.4 |
| نام | BaseXClient |
| نسخه کتابخانه | 8.4.4 |
| نگهدارنده | ['BaseX'] |
| ایمیل نگهدارنده | ['info@basex.org'] |
| نویسنده | Ben Greene |
| ایمیل نویسنده | BenJGreene+basex@gmail.com |
| آدرس صفحه اصلی | http://www.basex.org |
| آدرس اینترنتی | https://pypi.org/project/BaseXClient/ |
| مجوز | 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. |
A Python 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
-----------------------
.. code:: python
# -*- 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
-------------
.. code:: python
# -*- 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
-----------
.. code:: python
# -*- 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
------------------
.. code:: python
# -*- 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()
نحوه نصب
نصب پکیج whl BaseXClient-8.4.4:
pip install BaseXClient-8.4.4.whl
نصب پکیج tar.gz BaseXClient-8.4.4:
pip install BaseXClient-8.4.4.tar.gz