equal
deleted
inserted
replaced
21 * extid (aka external id, the primary key of an entity in the external source |
21 * extid (aka external id, the primary key of an entity in the external source |
22 from which it comes from) are stored in a varchar column encoded as a base64 |
22 from which it comes from) are stored in a varchar column encoded as a base64 |
23 string. This is because it should actually be Bytes but we want an index on |
23 string. This is because it should actually be Bytes but we want an index on |
24 it for fast querying. |
24 it for fast querying. |
25 """ |
25 """ |
|
26 from __future__ import print_function |
|
27 |
26 __docformat__ = "restructuredtext en" |
28 __docformat__ = "restructuredtext en" |
27 |
29 |
28 from cPickle import loads, dumps |
30 from cPickle import loads, dumps |
29 import cPickle as pickle |
31 import cPickle as pickle |
30 from threading import Lock |
32 from threading import Lock |
74 def execute(self, query, args=None): |
76 def execute(self, query, args=None): |
75 """Execute a query. |
77 """Execute a query. |
76 it's a function just so that it shows up in profiling |
78 it's a function just so that it shows up in profiling |
77 """ |
79 """ |
78 if server.DEBUG & server.DBG_SQL: |
80 if server.DEBUG & server.DBG_SQL: |
79 print 'exec', query, args |
81 print('exec', query, args) |
80 try: |
82 try: |
81 self.cu.execute(str(query), args) |
83 self.cu.execute(str(query), args) |
82 except Exception as ex: |
84 except Exception as ex: |
83 print "sql: %r\n args: %s\ndbms message: %r" % ( |
85 print("sql: %r\n args: %s\ndbms message: %r" % ( |
84 query, args, ex.args[0]) |
86 query, args, ex.args[0])) |
85 raise |
87 raise |
86 |
88 |
87 def fetchall(self): |
89 def fetchall(self): |
88 return self.cu.fetchall() |
90 return self.cu.fetchall() |
89 |
91 |
706 """Execute a query. |
708 """Execute a query. |
707 it's a function just so that it shows up in profiling |
709 it's a function just so that it shows up in profiling |
708 """ |
710 """ |
709 cursor = cnx.cnxset.cu |
711 cursor = cnx.cnxset.cu |
710 if server.DEBUG & server.DBG_SQL: |
712 if server.DEBUG & server.DBG_SQL: |
711 print 'exec', query, args, cnx.cnxset.cnx |
713 print('exec', query, args, cnx.cnxset.cnx) |
712 try: |
714 try: |
713 # str(query) to avoid error if it's a unicode string |
715 # str(query) to avoid error if it's a unicode string |
714 cursor.execute(str(query), args) |
716 cursor.execute(str(query), args) |
715 except Exception as ex: |
717 except Exception as ex: |
716 if self.repo.config.mode != 'test': |
718 if self.repo.config.mode != 'test': |
765 def doexecmany(self, cnx, query, args): |
767 def doexecmany(self, cnx, query, args): |
766 """Execute a query. |
768 """Execute a query. |
767 it's a function just so that it shows up in profiling |
769 it's a function just so that it shows up in profiling |
768 """ |
770 """ |
769 if server.DEBUG & server.DBG_SQL: |
771 if server.DEBUG & server.DBG_SQL: |
770 print 'execmany', query, 'with', len(args), 'arguments', cnx.cnxset.cnx |
772 print('execmany', query, 'with', len(args), 'arguments', cnx.cnxset.cnx) |
771 cursor = cnx.cnxset.cu |
773 cursor = cnx.cnxset.cu |
772 try: |
774 try: |
773 # str(query) to avoid error if it's a unicode string |
775 # str(query) to avoid error if it's a unicode string |
774 cursor.executemany(str(query), args) |
776 cursor.executemany(str(query), args) |
775 except Exception as ex: |
777 except Exception as ex: |