template1=# SELECT (pg_stat_file('base/'||oid ||'/PG_VERSION')).modification, datname FROM pg_database;
modification | datname
---------------------------+-----------------------------
2016-01-23 14:56:19+05:30 | template1
2016-01-23 14:56:20+05:30 | template0
2016-01-23 14:56:20+05:30 | postgres
2016-09-05 10:00:55+05:30 | pos.odoo.local
2016-09-06 19:01:40+05:30 | muda_live_20160815_18_15_00
2016-09-28 18:25:03+05:30 | muda_backup_20160815
2016-10-13 10:20:04+05:30 | bucaan_2016_10_13
2016-10-13 19:06:23+05:30 | muda_live_2016_08_19
2017-03-16 10:52:41+05:30 | test_v8
2016-09-03 15:32:49+05:30 | odoo.local
2016-09-03 15:49:00+05:30 | inventory.odoo.local
2016-09-03 18:17:31+05:30 | client-a.odoo.local
2016-09-03 18:42:15+05:30 | client-c.odoo.local
2016-09-03 20:01:43+05:30 | client-e.odoo.local
2016-03-21 18:36:22+05:30 | test_odoo_v8
2016-04-04 15:32:04+05:30 | openerp7_test
2016-06-03 11:19:57+05:30 | ozpool_3_6_2016
2016-08-10 11:40:50+05:30 | test_odoo_v9
2016-09-05 10:03:07+05:30 | client-g.odoo.local
2017-03-16 10:38:59+05:30 | bol_ept
2016-09-03 15:35:40+05:30 | s1.odoo.local
2016-09-22 18:00:33+05:30 | lunch.odoo.local
2016-09-03 18:28:19+05:30 | client-b.odoo.local
2016-09-03 18:44:53+05:30 | client-d.odoo.local
(24行)
在上面的列表中,前3个记录被跳过,只显示哪个记录 从当前日期起15天之前,我该怎么办?
因此,输出中只显示19行。
我想在eclipse中在控制台上打印答案。
答案 0 :(得分:0)
SELECT *
FROM (SELECT
(pg_stat_file('base/'||oid ||'/PG_VERSION')).modification,
datname
FROM pg_database
) dbs
WHERE datname NOT IN ('template1', 'template0', 'postgres')
AND age(modification) > INTERVAL '15 days';
答案 1 :(得分:0)
@api.multi
def get_database_list(self):
self._cr.execute("SELECT (pg_stat_file('base/'||oid ||'/PG_VERSION')).modification, datname FROM pg_database")
temp = []
res=self._cr.fetchall()
dt=datetime.utcnow() - timedelta(15)
for i in res:
dt1 = i[0].replace(tzinfo=None)
if(dt1 < dt):
result=self.env['ir.config_parameter'].search([('key','=','database.to.skip')])
test=result.value.split(',')
if i[1] not in test:
temp.append((i[1]))
print temp
<record id="default_database_management" model="ir.config_parameter">
<field name="key">database.to.skip</field>
<field name="value">template1,template0,postgres</field>
</record>