Compare commits

..

No commits in common. "a2da35691253271ffccdfd224ebac232f3b89403" and "6742c963abfa7b9ee7950ee2be40b49d4d754d24" have entirely different histories.

3 changed files with 25 additions and 8 deletions

View File

@ -2,6 +2,7 @@ from sqlalchemy.orm import Session
from typing import Annotated
from fastapi import Depends
from . import auth_utils, orm_models, pydantic_schemas
import random
import datetime
# Переменные для получения данных о мусорках с внешнего API
@ -38,7 +39,7 @@ def add_poems_to_db(db: Session):
# В конце каждой итерации добавляем в базу данных
db.add(poem)
db.commit()
# db.refresh(poem)
db.refresh(poem)
# close the file
f1.close()

View File

@ -1,7 +0,0 @@
from .orm_models import Poems
from .db import database
all_poems = database.query(Poems).all()
for to_delete in all_poems:
database.delete(to_delete)
database.commit()

23
back/main_stixi.py Normal file
View File

@ -0,0 +1,23 @@
def print_stixi():
import re
for a in range(1, 102):
f1 = open('text121.txt', encoding='utf-8', mode='r')#открыть фаил для чтения на русском
f1.seek(0)#перейти к началу
i=0
str1=""
stixi = []
#a=random.randint(1, 101)#можно добавить for от 1 до 101, тогда получится добавить в таблицу SQL
while str1 != f"стих {a}\n":
str1=f1.readline()
name=f1.readline()
re.sub('\n', '', name)
while str1 != f"стих {a+1}\n":
str1=f1.readline()
if(str1 != f"стих {a+1}\n"):
stixi.append(re.sub('\n', '', str1))#удаление /n и заключение в список
f1.close()
print(name)#сначала заполни таблицу названий, потом поменяй # местами у этой и нижней строчки
#print(stixi)#добавить добавление в список
print_stixi()