Beispiel #1
0
 def setUp(self):
     super().setUp()
     self.db_name = 'test.db'
     try:
         os.unlink(self.db_name)
     except OSError:
         pass
     create_database(self.db_name)
Beispiel #2
0
        string = value[::-1]
        arabic_number = 0
        last_arabic_value = 0
        for i in range(len(string)):
            roman_char = string[i]
            for row in rows:
                arabic_value = row[1]
                roman_value = row[2]
                if roman_char == roman_value:
                    arabic_number += arabic_value
                    if ((arabic_value < last_arabic_value)
                            and (last_arabic_value != 0)):
                        arabic_number -= arabic_value * 2
                        last_arabic_value = 0
                        break
                    last_arabic_value = arabic_value
                    break
        print(arabic_number)
        return arabic_number


#Проверка на существование таблицы с эквивалентами арабских и римских чисел
try:
    connect = sqlite3.connect('numbers.db')
    cursor = connect.cursor()
    cursor.execute(''' SELECT * FROM numbers''')
    rows = cursor.fetchall()
except sqlite3.OperationalError:
    create_db.create_database()
    print('Database was sucessfull created. Restart main script.')
Beispiel #3
0
 def setUp(self):
     create_db.create_database()
     config.ALLOWED_IPS = []
def main():
    write_from_web()
    database_password = ""
    database_action_verification = input("\n----------------------------\n"
                                         "Are you going to deposit pdbs in a database? (y) or (n)\n"
                                         "_______________________________\n")
    if database_action_verification == "y":
        database_password =  input("\n----------------------------\n"
                                         "What is the root database server password that is at localHost?\n"
                                         "_______________________________\n")
        db = mysql.connector.connect(user="******", password=database_password, host="localhost", database="proteins")
    while True:
        directory_path = input("\n----------------------------\n"
                               "Please enter the ABSOLUTE directory path where the .pdb files "
                               "are located\n"
                               "OR enter create to search computer for files\n"
                               "IF FILES ARE SCATTERED or EXACT LOCATION IS NOT KNOWN"
                               "-> use create command:\n"
                               "_______________________________\n")
        if directory_path == "create":
            directory_path = extract_pdb()
        if not os.path.exists(directory_path):
            print("\n---------------------------------\n"
                  "ERROR: directory path does not exist...try again\n"
                  "\n---------------------------------\n")
            continue
        break
    f = 0
    reset_directory = True
    start_time = time.time()
    while reset_directory:
        for file in os.listdir(directory_path):
            start_file_time = time.time()
            if re.search(regex_ext, file) == None:
                directory_path = input(
                    "\n----------------------------------\n"
                    "This directory path contains no pdb files.\n"
                    "Enter the ABSOLUTE location of the pdb files:\n"
                    "-----------------------------------\n")
                reset_directory = True
                break
            if re.search(regex_ext, file) != None:
                reset_directory = False
                current_file_name = file
                current_abs_path = directory_path + "/" + str(file)
                current_protein = Protein_Structure(current_abs_path, current_file_name)

                temp_list, current_protein.list_length, multiple_models, num_model, current_protein.num_atoms  = protein_info(current_abs_path)
                current_protein.particle_list = create_functional_list(temp_list,
                                                                       current_protein.list_length, multiple_models)

                if multiple_models:
                    current_protein.particle_list = breakup_models(current_protein.particle_list, num_model)
                    current_protein.num_atoms = len(current_protein.particle_list[0]) - 1
                if database_action_verification == "y":
                    create_database(db, current_protein, multiple_models)
                print("---file " + str(f+1) + " of " + str(len(os.listdir(directory_path))) + "---\n")
                print(current_protein.file_name + " was added to the database in %s seconds " % (time.time() - start_file_time))
                print("_________________________\n")
                f += 1
        db.close()
    print("--- %s seconds ---" % (time.time() - start_time))
Beispiel #5
0
 def add_to_db(self):
     create_db.create_database()
     create_db.create_table()
     create_db.insert(self.name, self.url, self.email, self.password)
Beispiel #6
0
#Routing program
#Used to route websites.

from create_db import create_database
DATABASE_FILENAME = "data.db"
create_database(DATABASE_FILENAME)

from flask import Flask, redirect, render_template, request, url_for
from server import app
from login import login_page
from security import has_access, logout, get_user, guest_register, get_pending_guests, approve_guest, deny_guest
from common import update
from create import view_courses, view_semesters
import json
from questionIO import *
from surveyIO import *
from save_response import save_response
from securityClasses import Admin, Staff, Student
from metrics import get_all_survey_responses
from courses import find_course


@app.route("/")
def index():
	update(request.remote_addr)
	return redirect("/login")

@app.route("/login", methods = ["GET", "POST"])
@app.route("/login/<role>/<page>", methods=["GET", "POST"])
def login(role = None, page = None):
	if page == None:
Beispiel #7
0
 def setUp(self):
     create_db.create_database("test_catalog.db")
     self.connectionT = sqlite3.connect("test_catalog.db")
     self.pointer = self.connectionT.cursor()
     self.data_movies = create_db.get_movies_data()
     self.data_actors = create_db.get_actors_data()
Beispiel #8
0
 def setUp(self):
     create_database(DATABASE_FILENAME)
Beispiel #9
0
 access_token = your_twitter_api_access_token
 access_secret = your_twitter_api_access_secret
 Mongodb_db_name = None
 
 #Initiate database connects ------------------------------------------------------------------
 ES = ET.connect_elasticsearch()
 cnx = mysql.connector.connect(user=<username>, password=<password>, host='127.0.0.1')
 cursor = cnx.cursor()
 Mdb = mongodb_connect(Mongodb_db_name)
 
 #Initiate schemas--------------------------------------------------------------------
 tweet_settings = get_ES_schema()
 mysql_tables = get_mysql_schema(t_users, t_tweets, t_loc, 
                                 t_hashtags, t_mention, t_reply, t_rt)
 #cdb.drop_database(cursor,test_db_utd)
 cdb.create_database(cursor,test_db_utd)
 cdb.use_database(cursor,test_db_utd)
 #ET.delete_index(ES,i_tweets_utd)
 #ET.create_index(ES,i_tweets_utd,tweet_settings)
 #tables.bulk_drop_table(cursor,[f'{t_reply}',f'{t_rt}',
 #                               f'{t_mention}',f'{t_hashtags}',
 #                               f'{t_tweets}',f'{t_users}',f'{t_loc}'])
 #tables.create_table(cursor,mysql_tables)
 keywords = ['Manchester United','ManUtd','MUFC','man utd']
 '''
 Some sample keywords
 keywords = ['Manchester United','ManUtd','red devils','MUFC','man utd']
 keywords = ['NBA']
 keywords = ['arsenal','CRYARS']
 keywords = ['Tottenham','Tottenham Hotspur','COYS','THFC','LFC','Liverpool','TOTLIV','YNWA']
 keywords = ['Manchester City','Man City','ManCity','AVLMCI','Aston Villa','AVFC']
Beispiel #10
0
def create_db():
    message = create_database()
    change_lbl_status(message)