コード例 #1
0
def demo():
    from connection import Connection, Database
    db = Database()
    print repr(db.list())

    cnx = Connection(dbname="demo", login="******", password="******")
    modules = Object(cnx, "ir.module.module")

    ids = modules.search([('state', '=', 'installed')])
    for p in modules.read(ids, ['name']):
        print p['name']
コード例 #2
0
def test_connection():

    # Creating a Connection
    new_instance = Database()
    cnx = new_instance.database_connector()
    cursor_variable = cnx.cursor()
    # Using the Connection
    try:
        SQL_Q = 'SELECT COUNT(*)  FROM company_list;'
        cursor_variable.execute(SQL_Q)
        row = cursor_variable.fetchall()
        print row
    except Exception as e:
        print "Exception Occured while Connecting to the Database"
        print "Error code:", e.errno  # error number
        print "SQLSTATE value:", e.sqlstate  # SQLSTATE value
        print "Error message:", e.msg  # error message
        print "Error:", e  # errno, sqlstate, msg values
コード例 #3
0
def get_db():
    db = Database(app.config['DB_USERNAME'], app.config['DB_PASSWORD'],
                  app.config['DB_HOST'], app.config['DB_SCHEMA'],
                  app.config['DB_USERTYPE'])
    return db
コード例 #4
0
from connection import Database
from pandas import read_excel, read_sql, DataFrame
import os
from config_db import Config
import datetime
from send_mail import SendMail
from ftplib import FTP
from log_error import logError
import pymssql

db = Database(Config)
log = logError()


class ProcessingFileANS:
    def downloadFile(self):
        try:
            ftp = FTP(Config.ftp_host)
            ftp.login(user=Config.ftp_user, passwd=Config.ftp_password)

            listing = []
            ftp.retrlines("LIST", listing.append)
            if len(listing) != 0:  #File existing to download
                words = listing[0].split(None, 8)
                filename = words[-1].lstrip()
                # download the file to folder repository
                local_filename = os.path.join(Config.ftp_folder, filename)
                lf = open(local_filename, "wb")
                ftp.retrbinary("RETR " + filename, lf.write, 8 * 1024)
                ftp.delete(filename)  #delete file
                lf.close()
コード例 #5
0
ファイル: second.py プロジェクト: NeoChithu/technoparkCrawler
from bs4 import BeautifulSoup
import urllib2, sys
import mysql.connector
from datetime import datetime

# Database Connection Related Imports
import sys, ssl
sys.path.insert(0, sys.path[0] + '\\database')
from connection import Database
# Creating a Connection
new_instance = Database()
cnx = new_instance.database_connector()
cursor_variable = cnx.cursor()


def job_details(url):
    # print url
    header = {'User-Agent': 'Mozilla/5.0'}
    req = urllib2.Request(url, headers=header)
    # page = urllib2.urlopen(req)
    gcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
    info = urllib2.urlopen(req, context=gcontext).read()
    soup = BeautifulSoup(info, 'html.parser')
    total_data = soup.find_all("div",
                               {"class": "det-text group-effect1 arrived"})[0]
    data = total_data.find_all("a", href=True)

    mail_id = ''

    for d in data: