Last active
August 29, 2015 13:56
-
-
Save scupython/9106602 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from models.dbase import db_session | |
from models.host import Host | |
from datetime import datetime | |
h = db_session.query(Host).filter(Host.public_ip=="58.68.229.43").filter(Host.deleted==False).one() | |
hs = db_session.query(Host).filter(Host.create_at > h.create_at).all() | |
for hh in hs: | |
print "|".join([hh.hostname, hh.public_ip, hh.private_ip, str(hh.idc_id), str(hh.cost), str(hh.price), str(hh.currency_id), hh.create_at.isoformat(), hh.h_info, hh.extra]) | |
with open('h.txt','r') as f: | |
for l in f.readlines(): | |
hn, pb,pr,idc, c, p, cid, ct,hi, note = l.split('|') | |
nh = Host(hostname=hn, public_ip=pb, private_ip=pr, idc_id=idc, cost=c, role='', price=p, currency_id=cid, create_at=datetime.strptime(ct, "%Y-%m-%dT%H:%M:%S"), h_info=hi, extra=note) | |
db_session.add(nh) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment