Beispiel #1
0
 def __init__(self, handlers):
     settings = dict(
         template_path=ROOT_JOIN('templates'),
         static_path=ROOT_JOIN('static'),
         debug=True,
         cookie_secret=Env.COOKIE_SEC,
         admin_user=Env.ADMIN_USER,
         default_handler_class=PyHub404,
         default_avatar=Env.AVATAR,
     )
     settings.update({'X-Spider-Key': Env.POST_KEY})
     super(BaseApplication, self).__init__(handlers=handlers, **settings)
     self.db = DB(Env)
     self.github = GitHub(Env.GITHUB_ID, Env.GITHUB_SEC,
                          Env.GITHUB_REDIRECT)
Beispiel #2
0
from model import DB
from model import Tuser
dbconn = DB()
session = dbconn.dbconnect()
print(session)
new_user = Tuser(id='12', name='Bob')
# 添加到session:
session.add(new_user)
# 提交即保存到数据库:
session.commit()
# 关闭session:
session.close()
Beispiel #3
0
import loaders
import sys

from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

from sqlalchemy.sql import or_

from model import Author, Book, DB
from dialogs import AuthDialog, AddAuthorDialog, AddBookDialog

from ui import Ui_ViewInfo

db = DB('library.db')


class MyForm(QMainWindow):

    db = db

    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.ui = Ui_ViewInfo()
        self.ui.setupUi(self)
        self.reload()
        self.nameFilters = {'JSON (*.json)': loaders.json_loader,
                            'XML (*.xml)': loaders.xml_loader}

    @staticmethod
    def _append_items(model, items):
import glob

from model import DB
from license_plate_detector import detect_license_plate
import os

license_number = 1234
db = DB()

images = r'images'
cropped_imgs = r'cropped'
path_to_directory = r'C:\Users\USER\PycharmProjects\hackathon2_flask'
imgs_path = os.path.join(path_to_directory, images)
cropped_imgs_path = os.path.join(path_to_directory, cropped_imgs)


def main_function():
    global license_number
    imgs_names = []
    for crp in os.listdir(cropped_imgs_path):
        imgs_names.append(crp)
    for img_name in imgs_names:
        # license_number = find_license_plate_number(os.path.join(cropped_imgs_path, img_name))
        license_number += 200
        _, date, time, area, _ = img_name.split('_')
        date = date.replace('-', '/')
        time = time.replace('-', ':')

        db.insert_report(license_number, date, time,
                         os.path.join(imgs_path, img_name), area)
Beispiel #5
0
from model import DB
from datetime import datetime
import csv

mydb = DB()

arr = []

with open('customer.csv') as csv_file:
    csv_reader = csv.reader(csv_file, delimiter=',')
    line_count = 0
    for row in csv_reader:
        if line_count == 0:
            print('header')
        else:
            print(row[-1])
            row[-1] = datetime.strptime(row[-1], '%d/%m/%Y %H:%M')
            arr.append(row)
        line_count += 1
        print(f'Processed {line_count} lines.')
mydb.insert_data(arr[1:])
Beispiel #6
0
 def __init__(self):
     self.db = DB()
     if not os.path.exists(db_file):
         os.mkdir(db_file)