Update of /cvsroot/monetdb/clients/src/examples/python
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19291

Added Files:
      Tag: Clients_1-20
        Makefile.ag sqlsample.py.in 
Log Message:
add code for testing the MonetDB python db-api


--- NEW FILE: Makefile.ag ---
# The contents of this file are subject to the MonetDB Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is the MonetDB Database System.
#
# The Initial Developer of the Original Code is CWI.
# Portions created by CWI are Copyright (C) 1997-2007 CWI.
# All Rights Reserved.

MTSAFE

scripts_py = {
        DIR = libdir/MonetDB/Tests
        SOURCES = sqlsample.py.in
}

--- NEW FILE: sqlsample.py.in ---
[EMAIL PROTECTED]@

# The contents of this file are subject to the MonetDB Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is the MonetDB Database System.
#
# The Initial Developer of the Original Code is CWI.
# Portions created by CWI are Copyright (C) 1997-2007 CWI.
# All Rights Reserved.

import MonetSQLdb
import sys

dbh = 
MonetSQLdb.Connection(dbname=sys.argv[2],host='localhost',port=sys.argv[1],lang='sql')

cursor = dbh.cursor();
cursor.execute('select 1;')
print cursor.fetchall()

cursor = dbh.cursor();
cursor.execute('select 2;')
print cursor.fetchone()

# deliberately executing a wrong SQL statement:
try:
        cursor.execute('( xyz 1);')
except: 
        print 'error'

cursor.execute('create table python_table (i smallint,s string);');
cursor.execute('insert into python_table values ( 3, \'three\');');
cursor.execute('insert into python_table values ( 7, \'seven\');');
cursor.execute('select * from python_table;');
print cursor.fetchall()


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to