From: brian z. <bz...@us...> - 2002-03-29 04:01:06
|
Update of /cvsroot/jython/jython/com/ziclix/python/sql In directory usw-pr-cvs1:/tmp/cvs-serv26901/com/ziclix/python/sql Modified Files: PyCursor.java Log Message: cursor is now file-like Index: PyCursor.java =================================================================== RCS file: /cvsroot/jython/jython/com/ziclix/python/sql/PyCursor.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** PyCursor.java 26 Mar 2002 02:46:36 -0000 1.18 --- PyCursor.java 29 Mar 2002 04:01:03 -0000 1.19 *************** *** 27,39 **** public class PyCursor extends PyObject implements ClassDictInit { - /** Field closed */ - private boolean closed; - /** Field fetch */ protected Fetch fetch; /** Field arraysize */ protected int arraysize; /** Field warnings */ protected PyObject warnings; --- 27,42 ---- public class PyCursor extends PyObject implements ClassDictInit { /** Field fetch */ protected Fetch fetch; + /** Field closed */ + private boolean closed; + /** Field arraysize */ protected int arraysize; + /** Field softspace */ + protected int softspace; + /** Field warnings */ protected PyObject warnings; *************** *** 83,86 **** --- 86,90 ---- this.arraysize = 1; + this.softspace = 0; this.closed = false; this.connection = connection; *************** *** 112,116 **** static { ! PyObject[] m = new PyObject[8]; m[0] = new PyString("close"); --- 116,120 ---- static { ! PyObject[] m = new PyObject[9]; m[0] = new PyString("close"); *************** *** 122,127 **** m[6] = new PyString("callproc"); m[7] = new PyString("next"); __methods__ = new PyList(m); ! m = new PyObject[8]; m[0] = new PyString("arraysize"); m[1] = new PyString("rowcount"); --- 126,132 ---- m[6] = new PyString("callproc"); m[7] = new PyString("next"); + m[8] = new PyString("write"); __methods__ = new PyList(m); ! m = new PyObject[9]; m[0] = new PyString("arraysize"); m[1] = new PyString("rowcount"); *************** *** 132,135 **** --- 137,141 ---- m[6] = new PyString("lastrowid"); m[7] = new PyString("updatecount"); + m[8] = new PyString("softspace"); __members__ = new PyList(m); } *************** *** 153,157 **** if ("arraysize".equals(name)) { ! arraysize = value.__int__().getValue(); } else if ("datahandler".equals(name)) { this.datahandler = (DataHandler)value.__tojava__(DataHandler.class); --- 159,165 ---- if ("arraysize".equals(name)) { ! this.arraysize = value.__int__().getValue(); ! } else if ("softspace".equals(name)) { ! this.softspace = value.__int__().getValue(); } else if ("datahandler".equals(name)) { this.datahandler = (DataHandler)value.__tojava__(DataHandler.class); *************** *** 171,174 **** --- 179,184 ---- if ("arraysize".equals(name)) { return Py.newInteger(arraysize); + } else if ("softspace".equals(name)) { + return Py.newInteger(softspace); } else if ("__methods__".equals(name)) { return __methods__; *************** *** 219,222 **** --- 229,233 ---- dict.__setitem__("executemany", new CursorFunc("executemany", 9, 1, 3, "execute sql with the parameter list")); dict.__setitem__("scroll", new CursorFunc("scroll", 10, 1, 2, "scroll the cursor in the result set to a new position according to mode")); + dict.__setitem__("write", new CursorFunc("write", 11, 1, "execute the sql written to this file-like object")); // hide from python *************** *** 430,435 **** * Return values are not defined. */ ! public void executemany(String sqlString, PyObject params, PyObject bindings, PyObject maxRows) { ! execute(sqlString, params, bindings, maxRows); } --- 441,446 ---- * Return values are not defined. */ ! public void executemany(PyObject sql, PyObject params, PyObject bindings, PyObject maxRows) { ! execute(sql, params, bindings, maxRows); } *************** *** 459,468 **** * Return values are not defined. * ! * @param sqlString sql string * @param params params for a prepared statement * @param bindings dictionary of (param index : SQLType binding) * @param maxRows integer value of max rows */ ! public void execute(final String sqlString, PyObject params, PyObject bindings, PyObject maxRows) { clear(); --- 470,489 ---- * Return values are not defined. * ! * @param sql sql string * @param params params for a prepared statement * @param bindings dictionary of (param index : SQLType binding) * @param maxRows integer value of max rows */ ! public void execute(final PyObject sql, PyObject params, PyObject bindings, PyObject maxRows) { ! ! if (sql == Py.None) { ! return; ! } ! ! final String sqlString = sql.__str__().toString(); ! ! if (sqlString.trim().length() == 0) { ! return; ! } clear(); *************** *** 918,922 **** case 5 : ! cursor.execute(arg.__str__().toString(), Py.None, Py.None, Py.None); return Py.None; --- 939,943 ---- case 5 : ! cursor.execute(arg, Py.None, Py.None, Py.None); return Py.None; *************** *** 932,936 **** case 9 : ! cursor.executemany(arg.__str__().toString(), Py.None, Py.None, Py.None); return Py.None; --- 953,957 ---- case 9 : ! cursor.executemany(arg, Py.None, Py.None, Py.None); return Py.None; *************** *** 941,944 **** --- 962,970 ---- return Py.None; + case 11 : + cursor.execute(arg, Py.None, Py.None, Py.None); + + return Py.None; + default : throw argCountError(1); *************** *** 962,966 **** case 5 : ! cursor.execute(arga.__str__().toString(), argb, Py.None, Py.None); return Py.None; --- 988,992 ---- case 5 : ! cursor.execute(arga, argb, Py.None, Py.None); return Py.None; *************** *** 975,979 **** case 9 : ! cursor.executemany(arga.__str__().toString(), argb, Py.None, Py.None); return Py.None; --- 1001,1005 ---- case 9 : ! cursor.executemany(arga, argb, Py.None, Py.None); return Py.None; *************** *** 1006,1010 **** case 5 : ! cursor.execute(arga.__str__().toString(), argb, argc, Py.None); return Py.None; --- 1032,1036 ---- case 5 : ! cursor.execute(arga, argb, argc, Py.None); return Py.None; *************** *** 1016,1020 **** case 9 : ! cursor.executemany(arga.__str__().toString(), argb, argc, Py.None); return Py.None; --- 1042,1046 ---- case 9 : ! cursor.executemany(arga, argb, argc, Py.None); return Py.None; *************** *** 1050,1054 **** case 5 : ! cursor.execute(sql.__str__().toString(), params, bindings, maxrows); return Py.None; --- 1076,1080 ---- case 5 : ! cursor.execute(sql, params, bindings, maxrows); return Py.None; *************** *** 1060,1064 **** case 9 : ! cursor.executemany(sql.__str__().toString(), params, bindings, maxrows); return Py.None; --- 1086,1090 ---- case 9 : ! cursor.executemany(sql, params, bindings, maxrows); return Py.None; |