]>
git.datanom.net - pwp.git/blob - app/DB/base.py
2 logging
.basicConfig(level
=logging
.INFO
)
3 logger
= logging
.getLogger(__name__
)
7 def query(self
, sql
, placeholders
):
9 cur
= self
.conn
.cursor()
11 cur
.execute(sql
, placeholders
)
13 except Exception as e
:
14 logger
.error("{0}".format(e
))
21 def update(self
, sql
, placeholders
):
23 cur
= self
.conn
.cursor()
25 cur
.execute(sql
, placeholders
)
28 except Exception as e
:
36 def insert(self
, sql
, placeholders
):
38 cur
= self
.conn
.cursor()
40 cur
.execute(sql
, placeholders
)
41 if self
.__class
__.__name
__ == 'Postgres':
42 cur
.execute('select lastval()')
43 lastid
= cur
.fetchone()[0]
45 lastid
= cur
.lastrowid
47 except Exception as e
:
56 cur
= self
.conn
.cursor()
58 if self
.__class
__.__name
__ == 'Mysql':
59 for r
in cur
.execute(sql
, multi
=True):
64 except Exception as e
:
71 #print("%s: deleted" % self.__class__.__name__)
75 except AttributeError:
This page took 0.096519 seconds and 6 git commands to generate.