from models.author import Author from models.data_base import Data_base if __name__ == '__main__': db = Data_base().library a = Author( { 'first': input("F_name: "), 'second': input("S_name: "), 'addactive': input("Add_name: ") or None }, { 'day': 2, 'month': 6, 'year': 1920 }, ) print(a.name['first']) date = [int(i) for i in input("date: ").split()] date.extend([None, None]) a.born['day'], a.born['month'], a.born[ 'year'] = date[2] or None, date[1] or None, date[0] or None a.img = open( r"C:\Users\sashk\PycharmProjects\Library\static\image\\" + input("Img: "), 'rb') a.save()
from models.author import Author from models.editor import Editor from models.book import Book client = pymongo.MongoClient( "mongodb+srv://nico:[email protected]/test?retryWrites=true&w=majority" ) db = client.mydb authors = db.authors editors = db.editors books = db.books nico_author = Author(authors, 'Nicolas', 'Blanchard') nico_author.save() kath_editor = Editor(editors, 'abcabcd', 'Kathleen Editor') kath_editor.save() bruxelles_book = Book(books, '1231232', 'Bruxelles: la ville') bruxelles_book.editor = kath_editor._id bruxelles_book.add_author(nico_author._id) bruxelles_book.save() nico_author.add_book(bruxelles_book._id) nico_author.save() kath_editor.add_book(bruxelles_book._id) kath_editor.save()