Пример #1
0
 def execute(self, query, params=None):
     if params is None:
         params = []
     else:
         params = self._format_params(params)
     args = [(':arg%d' % i) for i in range(len(params))]
     # cx_Oracle wants no trailing ';' for SQL statements.  For PL/SQL, it
     # it does want a trailing ';' but not a trailing '/'.  However, these
     # characters must be included in the original query in case the query
     # is being passed to SQL*Plus.
     if query.endswith(';') or query.endswith('/'):
         query = query[:-1]
     query = smart_str(query, self.charset) % tuple(args)
     self._guess_input_sizes([params])
     return Database.Cursor.execute(self, query, self._param_generator(params))
Пример #2
0
 def executemany(self, query, params=None):
     try:
       args = [(':arg%d' % i) for i in range(len(params[0]))]
     except (IndexError, TypeError):
       # No params given, nothing to do
       return None
     # cx_Oracle wants no trailing ';' for SQL statements.  For PL/SQL, it
     # it does want a trailing ';' but not a trailing '/'.  However, these
     # characters must be included in the original query in case the query
     # is being passed to SQL*Plus.
     if query.endswith(';') or query.endswith('/'):
         query = query[:-1]
     query = smart_str(query, self.charset) % tuple(args)
     formatted = [self._format_params(i) for i in params]
     self._guess_input_sizes(formatted)
     return Database.Cursor.executemany(self, query, [self._param_generator(p) for p in formatted])
Пример #3
0
 def execute(self, query, params=None):
     if params is None:
         params = []
     else:
         params = self._format_params(params)
     args = [(":arg%d" % i) for i in range(len(params))]
     # cx_Oracle wants no trailing ';' for SQL statements.  For PL/SQL, it
     # it does want a trailing ';' but not a trailing '/'.  However, these
     # characters must be included in the original query in case the query
     # is being passed to SQL*Plus.
     if query.endswith(";") or query.endswith("/"):
         query = query[:-1]
     query = smart_str(query, self.charset) % tuple(args)
     self._guess_input_sizes([params])
     try:
         return self.cursor.execute(query, self._param_generator(params))
     except DatabaseError, e:
         # cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400.
         if e.args[0].code == 1400 and not isinstance(e, IntegrityError):
             e = IntegrityError(e.args[0])
         raise e
Пример #4
0
 def execute(self, query, params=None):
     if params is None:
         params = []
     else:
         params = self._format_params(params)
     args = [(':arg%d' % i) for i in range(len(params))]
     # cx_Oracle wants no trailing ';' for SQL statements.  For PL/SQL, it
     # it does want a trailing ';' but not a trailing '/'.  However, these
     # characters must be included in the original query in case the query
     # is being passed to SQL*Plus.
     if query.endswith(';') or query.endswith('/'):
         query = query[:-1]
     query = smart_str(query, self.charset) % tuple(args)
     self._guess_input_sizes([params])
     try:
         return Database.Cursor.execute(self, query, self._param_generator(params))
     except DatabaseError, e:
         # cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400.
         if e.args[0].code == 1400 and not isinstance(e, IntegrityError):
             e = IntegrityError(e.args[0])
         raise e
Пример #5
0
 def executemany(self, query, params=None):
     try:
         args = [(":arg%d" % i) for i in range(len(params[0]))]
     except (IndexError, TypeError):
         # No params given, nothing to do
         return None
     # cx_Oracle wants no trailing ';' for SQL statements.  For PL/SQL, it
     # it does want a trailing ';' but not a trailing '/'.  However, these
     # characters must be included in the original query in case the query
     # is being passed to SQL*Plus.
     if query.endswith(";") or query.endswith("/"):
         query = query[:-1]
     query = smart_str(query, self.charset) % tuple(args)
     formatted = [self._format_params(i) for i in params]
     self._guess_input_sizes(formatted)
     try:
         return self.cursor.executemany(query, [self._param_generator(p) for p in formatted])
     except DatabaseError, e:
         # cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400.
         if e.args[0].code == 1400 and not isinstance(e, IntegrityError):
             e = IntegrityError(e.args[0])
         raise e
Пример #6
0
 def executemany(self, query, params=None):
     try:
         args = [(':arg%d' % i) for i in range(len(params[0]))]
     except (IndexError, TypeError):
         # No params given, nothing to do
         return None
     # cx_Oracle wants no trailing ';' for SQL statements.  For PL/SQL, it
     # it does want a trailing ';' but not a trailing '/'.  However, these
     # characters must be included in the original query in case the query
     # is being passed to SQL*Plus.
     if query.endswith(';') or query.endswith('/'):
         query = query[:-1]
     query = convert_unicode(query % tuple(args), self.charset)
     formatted = [self._format_params(i) for i in params]
     self._guess_input_sizes(formatted)
     try:
         return self.cursor.executemany(
             query, [self._param_generator(p) for p in formatted])
     except DatabaseError, e:
         # cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400.
         if e.args[0].code == 1400 and not isinstance(e, IntegrityError):
             e = IntegrityError(e.args[0])
         raise e