MCPcopy Create free account
hub / github.com/apache/cloudstack / execute

Method execute

tools/marvin/marvin/dbConnection.py:35–56  ·  view source on GitHub ↗
(self, sql=None, params=None, db=None)

Source from the content-addressed store, hash-verified

33 self.database = db
34
35 def execute(self, sql=None, params=None, db=None):
36 if sql is None:
37 return None
38
39 resultRow = []
40 with contextlib.\
41 closing(mysql.connector.connect(host=str(self.host),
42 port=int(self.port),
43 user=str(self.user),
44 password=str(self.passwd),
45 db=str(self.database) if not db else db)) as conn:
46 conn.autocommit = True
47 with contextlib.closing(conn.cursor(buffered=True)) as cursor:
48 cursor.execute(sql, params)
49 try:
50 if sql.lower().startswith('select') and cursor.rowcount > 0:
51 # we have more than just the row count/success
52 resultRow = cursor.fetchall()
53 except errors.InterfaceError:
54 # Raised on empty result - DML
55 resultRow = []
56 return resultRow
57
58 def executeSqlFromFile(self, fileName=None):
59 if fileName is None:

Callers 1

executeSqlFromFileMethod · 0.95

Calls 3

intFunction · 0.85
connectMethod · 0.65
executeMethod · 0.65

Tested by

no test coverage detected