i am using Python to get a list of databases that were more than 30 days old. So far i have been able to get the list of the databases from here. And this is my code :-
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)
How can i adjust the code to get list of databases 30 days older or more? Thanks for the help.
If you are able to somehow pull a create_date
value for the DB you could use something like this using the timedelta object:
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)
You'll have to adjust this as needed but this gives you a general idea