forked from MonetDB/pymonetdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PKG-INFO
121 lines (99 loc) · 4.64 KB
/
PKG-INFO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
Metadata-Version: 1.1
Name: pymonetdb
Version: 1.0
Summary: Native MonetDB client Python API
Home-page: http://www.monetdb.org/
Author: MonetDB BV
Author-email: info@monetdb.org
License: MPLv2.0
Download-URL: http://dev.monetdb.org/downloads/sources/Oct2014/python2-monetdb-11.19.3.tar.gz
Description: .. This Source Code Form is subject to the terms of the Mozilla Public
.. License, v. 2.0. If a copy of the MPL was not distributed with this
.. file, You can obtain one at http://mozilla.org/MPL/2.0/.
..
.. Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
.. This document is written in reStructuredText (see
http://docutils.sourceforge.net/ for more information).
Use ``rst2html.py`` to convert this file to HTML.
==========================================
The MonetDB MAPI and SQL client python API
==========================================
Introduction
============
This is the new native python client API. This API is cross-platform,
and doesn't depend on any monetdb libraries. It has support for
python 2.5+ and is Python DBAPI 2.0 compatible.
Installation
============
To install the MonetDB python API run the following command from the
python source directory::
# python setup.py install
That's all, now you are ready to start using the API.
Documentation
=============
The python code is well documented, so if you need to find
documentation you should have a look at the source code. Below is an
interactive example on how to use the monetdb SQL API which should get
you started quite fast.
Examples
========
There are some examples in the 'examples' folder, but here are is a
line by line example of the SQL API::
> # import the SQL module
> import monetdb.sql
>
> # set up a connection. arguments below are the defaults
> connection = monetdb.sql.connect(username="monetdb", password="monetdb", hostname="localhost", database="demo")
>
> # create a cursor
> cursor = connection.cursor()
>
> # increase the rows fetched to increase performance (optional)
> cursor.arraysize = 100
>
> # execute a query (return the number of rows to fetch)
> cursor.execute('SELECT * FROM tables')
26
>
> # fetch only one row
> cursor.fetchone()
[1062, 'schemas', 1061, None, 0, True, 0, 0]
>
> # fetch the remaining rows
> cursor.fetchall()
[[1067, 'types', 1061, None, 0, True, 0, 0],
[1076, 'functions', 1061, None, 0, True, 0, 0],
[1085, 'args', 1061, None, 0, True, 0, 0],
[1093, 'sequences', 1061, None, 0, True, 0, 0],
[1103, 'dependencies', 1061, None, 0, True, 0, 0],
[1107, 'connections', 1061, None, 0, True, 0, 0],
[1116, '_tables', 1061, None, 0, True, 0, 0],
...
[4141, 'user_role', 1061, None, 0, True, 0, 0],
[4144, 'auths', 1061, None, 0, True, 0, 0],
[4148, 'privileges', 1061, None, 0, True, 0, 0]]
>
> # Show the table meta data
> cursor.description
[('id', 'int', 4, 4, None, None, None),
('name', 'varchar', 12, 12, None, None, None),
('schema_id', 'int', 4, 4, None, None, None),
('query', 'varchar', 168, 168, None, None, None),
('type', 'smallint', 1, 1, None, None, None),
('system', 'boolean', 5, 5, None, None, None),
('commit_action', 'smallint', 1, 1, None, None, None),
('temporary', 'tinyint', 1, 1, None, None, None)]
If you would like to communicate with the database at a lower level
you can use the MAPI library::
> from monetdb import mapi
> server = mapi.Server()
> server.connect(hostname="localhost", port=50000, username="monetdb", password="monetdb", database="demo", language="sql")
> server.cmd("sSELECT * FROM tables;")
...
Platform: UNKNOWN
Classifier: Topic :: Database
Classifier: Topic :: Database :: Database Engines/Servers
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
Classifier: Programming Language :: Python :: 2