Exemplo n.º 1
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from sqlalchemy import create_engine

from database.models import Base
from core.config import _database_config


DATABASE = _database_config()["DATABASE"]


def sqlite_create_tables():
    """
    when using sqlite database, this is the function that is used to create the database schema for the first time when
    you run the nettacker module.

    Args:
        None

    Returns:
        True if success otherwise False
    """
    try:
        db_engine = create_engine('sqlite:///{0}'.format(DATABASE))
        Base.metadata.create_all(db_engine)
        return True
    except Exception as _:
        return False

Exemplo n.º 2
0
import json
import time
from flask import jsonify
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from database.models import HostsLog, Report, Update_Log
from core.alert import warn
from core.alert import info
from core.alert import messages
from core.compatible import version
from core._time import now
from core import compatible
from api.api_core import __structure
from core.config import _database_config

DB = _database_config()["DB"]
USER = _database_config()["USERNAME"]
PASSWORD = _database_config()["PASSWORD"]
HOST = _database_config()["HOST"]
PORT = _database_config()["PORT"]
DATABASE = _database_config()["DATABASE"]

#Python2 hack for flake8
try:
    reload
except NameError:

    def reload(dummy):
        return dummy