如何解决Orientdb python 列表数据库?
我正在使用 Python 获取超过 30 天的数据库列表。到目前为止,我已经能够从 here 获取数据库列表。这是我的代码:-
import pyorient
def list_orient_databases(name):
# Use a breakpoint in the code line below to debug your script.
print(f'{name}')
client = pyorient.OrientDB("10.121.3.55",2525)
session_id = client.connect("admin","admin")
db_names = client.db_list().__getattr__('databases')
db_count = 0
for db_name in db_names:
print(db_name)
如何调整代码以获取 30 天或更长时间的数据库列表?感谢您的帮助。
解决方法
如果您能够以某种方式为数据库提取 create_date
值,您可以使用 timedelta 对象使用类似的东西:
from datetime import datetime,timedelta
d = datetime.today() - timedelta(days=30)
# 'X' would be whatever the database create date name parameter is
for db_name in db_names:
if db_name['X'] <= d:
print(db_name)
您必须根据需要进行调整,但这为您提供了一个总体思路
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。