def makePoint(c): values = ["<BI",1,1] [ptrn,coords] = pts(c.getPart(0)) values[0]+=ptrn values.extend(coords) return Binary(pack(*values))
def makeMultiPoint(c): values = ["<BI", 1, 4] [ptrn, coords] = mp(c) values[0] += ptrn values.extend(coords) return Binary(pack(*values))
track_id = database.addTrack(track_title) del database print("=> Processing %s, id: %d" % (track_title, track_id)) wavdata = sound.read(track) Fe = wavdata.getframerate() frame_number = int(wavdata.getnframes() / frame_size) print("%d frames to process for this track" % frame_number) progress = 0 for i in range(frame_number): s = wavdata.readframes(frame_size) s = np.frombuffer(s, dtype='<i2') y = mp.sparse(s) keys = mp.extractKeys(y) query.extend([(Binary(hash_key)[0:5], track_id, int(i * frame_size + offset)) for (hash_key, offset) in keys]) if i * 100 / frame_number >= progress + 10: progress = i * 100 / frame_number #print("%d%%," % (progress,)), database = Database() database.addFingerprint(query) del database print("100%")
def adapt_array(arr): out = BytesIO() save(out, arr) out.seek(0) return Binary(out.read())
from ..utils import UnicodeCsvReader from ..compare import _is_nscontainer from ..allow import _expects_multiple_params def _is_sortable(obj): """Returns True if *obj* is sortable else returns False.""" try: sorted([obj, obj]) return True except TypeError: return False # The SQLite BLOB/Binary type in sortable Python 2 but unsortable in Python 3. _unsortable_blob_type = not _is_sortable(Binary(b'0')) def _sqlite_sortkey(value): """Key function for use with sorted(), min(), max(), etc. that makes a best effort to match SQLite ORDER BY behavior for supported classes. From SQLite docs: "...values with storage class NULL come first, followed by INTEGER and REAL values interspersed in numeric order, followed by TEXT values in collating sequence order, and finally BLOB values in memcmp() order." For more details see "Datatypes In SQLite Version 3" section
'online': get_online, 'reg': get_registered, 'ban': ban, 'unban': unban, 'role': change_role } # Create database, if not created connection = create_connection("data.sqlite3") execute_query(connection, queries['create_users_table']) execute_query(connection, queries['create_messages_table']) # Create administrator, if the server was run with arguments [username] [password] if len(argv) == 3: password_hash = codec(argv[2], 1) password_hash = Binary(password_hash) data_dict = {'username': argv[1], 'password_hash': password_hash} create_admin = f"INSERT INTO users (username, password_hash, role, registered)" \ f"VALUES (:username, :password_hash, 3, strftime('%s','now'))" execute_query(connection, create_admin, data_dict) else: print( "ATTENTION: You haven't specified 2 additional arguments: [username] [password]\n" "An account with administrator role wasn't created\n") connection.close() @app.route("/") def hello():