diff options
Diffstat (limited to 'pb/lib/Db/__init__.py')
| -rw-r--r-- | pb/lib/Db/__init__.py | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/pb/lib/Db/__init__.py b/pb/lib/Db/__init__.py deleted file mode 100644 index ac7ca17..0000000 --- a/pb/lib/Db/__init__.py +++ /dev/null @@ -1,71 +0,0 @@ -# coding: utf-8 -import time, sys -HOST = "lalalizard.com" -USER = "asdfus" -PASSWORD = "gTYgT&M6q" -DATABASE = "asdfus" - - -from sqlalchemy import Column, Integer, LargeBinary, String, create_engine, sql -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import sessionmaker -_NULL = sql.null() - -Base = declarative_base() -metadata = Base.metadata - -class ImCmd(Base): - __tablename__ = 'im_cmd' - id = Column(Integer, primary_key=True) - date = Column(Integer) - remote_addr = Column(String(16)) - name = Column(String(16)) - url = Column(String(256)) - dir = Column(String(2)) - oldfile = Column(String(256)) - newfile = Column(String(256)) - cmd = Column(LargeBinary) - dataobj = Column(LargeBinary) - tag = Column(String(50)) - -class Db(object): - def __init__(self): - engine = create_engine('mysql://{}:{}@{}/{}'.format( - USER, - PASSWORD, - HOST, - DATABASE - )) - Session = sessionmaker(bind=engine) - self.session = Session() - - def insert_cmd ( - self, - date=time.time(), - remote_addr=_NULL, - username=_NULL, - url=_NULL, - directory=_NULL, - oldfile=_NULL, - newfile=_NULL, - cmd=_NULL, - dataobj=_NULL, - tag=_NULL): - try: - entry = ImCmd( - date=date, - remote_addr=remote_addr, - name=username, - url=url, - dir=directory, - oldfile=oldfile, - newfile=newfile, - cmd=cmd, - dataobj=dataobj, - tag=tag - ) - self.session.add(entry) - self.session.commit() - except Exception as e: - sys.stderr.write("Unable to commit database entry"); - sys.stderr.write(str(e)) |
