chenjunkai 7 years ago
parent
commit
e807825905
3 changed files with 0 additions and 164 deletions
  1. 0 60
      Ansjer/test/util/mongodb.py
  2. 0 91
      Ansjer/test/util/sql.py
  3. 0 13
      Ansjer/test/util/time.py

+ 0 - 60
Ansjer/test/util/mongodb.py

@@ -1,60 +0,0 @@
-#!/usr/bin/env python3  
-# -*- coding: utf-8 -*-  
-"""
-@Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
-@AUTHOR: ASJRD018
-@NAME: Ansjer
-@software: PyCharm
-@DATE: 2018/6/15 14:18
-@Version: python3.6
-@MODIFY DECORD:ansjer dev
-@file: mongodb.py
-@Contact: chanjunkai@163.com
-"""
-# !/usr/bin/python3
-import pymongo
-
-class mongodb(object):
-
-    def __init__(self):
-        myclient = pymongo.MongoClient('mongodb://localhost:27017/')
-        # myclient = pymongo.MongoClient('mongodb://192.168.136.45:27017/')
-        self.myclient = myclient
-        self.db = myclient['ansjertest']
-
-    def check_db_exist(self, database):
-        dblist = self.myclient.database_names()
-        if database in dblist:
-            return True
-        else:
-            return False
-
-    def insert_one(self, col, data):
-        column = self.db[col]
-        res = column.insert_one(data)
-        return res.inserted_id
-
-    def findAll(self, col,page,line,query):
-        collist = self.db.collection_names()
-        if col in collist:  # 判断 customers 集合是否存在
-            qs = self.db[col].find(query)
-            count = qs.count()
-            if page != 0 and line != 0:
-                qs = qs.sort("_id", -1).skip((page - 1) * 10).limit(line)
-            # print(count)
-            data = []
-            for q in qs:
-                data.append(q)
-            res_dict = {'data': data, 'count': count}
-            return res_dict
-        else:
-            print("集合不存在!")
-            return False
-
-if __name__ == '__main__':
-    mdb = mongodb()
-    col = "log_device_operation"
-    data = {"name": "111", "address": "Lowstreet 27"}
-    flag = mdb.insert_one(col=col, data=data)
-    # qs = mdb.findAll(col=col, page=1, line=100,query={'name':'Peter'})
-    # print(qs)

+ 0 - 91
Ansjer/test/util/sql.py

@@ -1,91 +0,0 @@
-'''
-@author chenjunkai
-@time 20180612
-'''
-"""
-一般 Python 用于连接 MySQL 的工具:pymysql
-"""
-import pymysql.cursors
-
-connection = pymysql.connect(host='localhost',
-                             user='root',
-                             password='1234',
-                             db='test',
-                             charset='utf8mb4',
-                             cursorclass=pymysql.cursors.DictCursor)
-
-
-# 保存评论
-def insert_comments(music_id, comments, detail, connection0):
-    with connection0.cursor() as cursor:
-        sql = "INSERT INTO `comments` (`MUSIC_ID`, `COMMENTS`, `DETAILS`) VALUES (%s, %s, %s)"
-        cursor.execute(sql, (music_id, comments, detail))
-    connection0.commit()
-
-
-# 保存音乐
-def insert_music(music_id, music_name, album_id):
-    with connection.cursor() as cursor:
-        sql = "INSERT INTO `musics` (`MUSIC_ID`, `MUSIC_NAME`, `ALBUM_ID`) VALUES (%s, %s, %s)"
-        cursor.execute(sql, (music_id, music_name, album_id))
-    connection.commit()
-
-
-# 保存专辑
-def insert_album(album_id, artist_id):
-    with connection.cursor() as cursor:
-        sql = "INSERT INTO `albums` (`ALBUM_ID`, `ARTIST_ID`) VALUES (%s, %s)"
-        cursor.execute(sql, (album_id, artist_id))
-    connection.commit()
-
-
-# 保存歌手
-def insert_artist(artist_id, artist_name):
-    with connection.cursor() as cursor:
-        sql = "INSERT INTO `artists` (`ARTIST_ID`, `ARTIST_NAME`) VALUES (%s, %s)"
-        cursor.execute(sql, (artist_id, artist_name))
-    connection.commit()
-
-
-# 获取所有歌手的 ID
-def get_all_artist():
-    with connection.cursor() as cursor:
-        sql = "SELECT `ARTIST_ID` FROM `artists` ORDER BY ARTIST_ID"
-        cursor.execute(sql, ())
-        return cursor.fetchall()
-
-
-# 获取所有专辑的 ID
-def get_all_album():
-    with connection.cursor() as cursor:
-        sql = "SELECT `ALBUM_ID` FROM `albums` ORDER BY ALBUM_ID"
-        cursor.execute(sql, ())
-        return cursor.fetchall()
-
-
-# 获取所有音乐的 ID
-def get_all_music():
-    with connection.cursor() as cursor:
-        sql = "SELECT `MUSIC_ID` FROM `musics` ORDER BY MUSIC_ID"
-        cursor.execute(sql, ())
-        return cursor.fetchall()
-
-
-# 获取前一半音乐的 ID
-def get_before_music():
-    with connection.cursor() as cursor:
-        sql = "SELECT `MUSIC_ID` FROM `musics` ORDER BY MUSIC_ID LIMIT 0, 800000"
-        cursor.execute(sql, ())
-        return cursor.fetchall()
-
-
-# 获取后一半音乐的 ID
-def get_after_music():
-    with connection.cursor() as cursor:
-        sql = "SELECT `MUSIC_ID` FROM `musics` ORDER BY MUSIC_ID LIMIT 800000, 1197429"
-        cursor.execute(sql, ())
-        return cursor.fetchall()
-
-
-def dis_connect():
-    connection.close()

+ 0 - 13
Ansjer/test/util/time.py

@@ -1,13 +0,0 @@
-
-import time, datetime
-print(datetime.datetime.now())
-def gettime():
-    for x in range(24):
-        a = datetime.datetime.now().strftime("%Y-%m-%d") + " %2d:00:00" % x
-        timeArray = time.strptime(a, "%Y-%m-%d %H:%M:%S")
-        timeStamp = int(time.mktime(timeArray))
-        print(timeStamp)
-if __name__ == "__main__":
-    gettime()
-
-