I tried to generate ObjectId (primary key) with pymongo

reference: https://docs.mongodb.org/manual/reference/object-id/ https://api.mongodb.org/python/current/api/bson/objectid.html

python


# coding=utf-8

from bson.objectid import ObjectId

print "# GEN"
oids = []
for x in range(10):
    oid = str(ObjectId())
    print oid
    oids.append(oid)

print "# DESC"
oids.sort(reverse=True)

for oid in oids:
    print oid

print "# ASC"
oids.sort()

for oid in oids:
    print oid


GEN 5660f8b837dbc4066fd1c26b 5660f8b837dbc4066fd1c26c 5660f8b837dbc4066fd1c26d 5660f8b837dbc4066fd1c26e 5660f8b837dbc4066fd1c26f 5660f8b837dbc4066fd1c270 5660f8b837dbc4066fd1c271 5660f8b837dbc4066fd1c272 5660f8b837dbc4066fd1c273 5660f8b837dbc4066fd1c274 DESC 5660f8b837dbc4066fd1c274 5660f8b837dbc4066fd1c273 5660f8b837dbc4066fd1c272 5660f8b837dbc4066fd1c271 5660f8b837dbc4066fd1c270 5660f8b837dbc4066fd1c26f 5660f8b837dbc4066fd1c26e 5660f8b837dbc4066fd1c26d 5660f8b837dbc4066fd1c26c 5660f8b837dbc4066fd1c26b ASC 5660f8b837dbc4066fd1c26b 5660f8b837dbc4066fd1c26c 5660f8b837dbc4066fd1c26d 5660f8b837dbc4066fd1c26e 5660f8b837dbc4066fd1c26f 5660f8b837dbc4066fd1c270 5660f8b837dbc4066fd1c271 5660f8b837dbc4066fd1c272 5660f8b837dbc4066fd1c273 5660f8b837dbc4066fd1c274

Process finished with exit code 0

Recommended Posts

I tried to generate ObjectId (primary key) with pymongo
I tried to automatically generate a password with Python3
I tried to visualize AutoEncoder with TensorFlow
I tried to get started with Hy
I tried to implement CVAE with PyTorch
Generate PowerPoint material for "I tried to sing with XX" [python-pptx]
I tried to solve TSP with QAOA
I tried to predict next year with AI
I tried to use lightGBM, xgboost with Boruta
I tried to learn logical operations with TF Learn
I tried to move GAN (mnist) with keras
I implemented DCGAN and tried to generate apples
I tried to save the data with discord
I tried to integrate with Keras in TFv1.1
I tried to get CloudWatch data with Python
I tried to detect an object with M2Det!
I tried to automate sushi making with python
I tried to predict Titanic survival with PyCaret
I tried to generate a random character string
I tried to operate Linux with Discord Bot
I tried to study DP with Fibonacci sequence
I tried to start Jupyter with Amazon lightsail
I tried to judge Tsundere with Naive Bayes
I tried to debug.
I tried to paste
I tried to learn the sin function with chainer
I tried to move machine learning (ObjectDetection) with TouchDesigner
I tried to create a table only with Django
I tried to extract features with SIFT of OpenCV
I tried to move Faster R-CNN quickly with pytorch
I tried to read and save automatically with VOICEROID2 2
I tried to implement and learn DCGAN with PyTorch
I tried to implement Minesweeper on terminal with python
I tried to get started with blender python script_Part 01
I tried to touch the CSV file with Python
I tried to draw a route map with Python
I tried to solve the soma cube with python
I tried to automatically read and save with VOICEROID2
I tried to get started with blender python script_Part 02
I tried to implement an artificial perceptron with python
I tried to build ML Pipeline with Cloud Composer
I tried to implement time series prediction with GBDT
I tried to uncover our darkness with Chatwork API
[Introduction to Pytorch] I tried categorizing Cifar10 with VGG16 ♬
I tried to solve the problem with Python Vol.1
I tried to analyze J League data with Python
I tried to implement Grad-CAM with keras and tensorflow
I tried to make an OCR application with PySimpleGUI
I tried to implement SSD with PyTorch now (Dataset)
I tried to interpolate Mask R-CNN with Optical Flow
I tried to step through Bayesian optimization. (With examples)
I tried to find an alternating series with tensorflow
[Introduction to AWS] I tried playing with voice-text conversion ♪
I tried to solve AOJ's number theory with Python
I tried fp-growth with python
I tried scraping with Python
I tried to learn PredNet
I tried Learning-to-Rank with Elasticsearch!
I tried to organize SVM.
I tried clustering with PyCaret
I tried to implement PCANet