added article.py
This commit is contained in:
@@ -83,6 +83,7 @@ def get_similar():
|
||||
return similar_data
|
||||
|
||||
|
||||
|
||||
def insert_data(title, text, link, embedding, similar_d):
|
||||
conn = psycopg2.connect(
|
||||
host=host,
|
||||
@@ -97,9 +98,9 @@ def insert_data(title, text, link, embedding, similar_d):
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute('''
|
||||
INSERT INTO vectorsvevijesti (title, text, link, embedding, similar_d, time)
|
||||
VALUES (%s, %s, %s, %s, %s ,%s);
|
||||
''', (title, text, link, embedding , similar_d, c_time))
|
||||
INSERT INTO vectorsvevijesti (title, text, link, embedding, similar_d, time, ready)
|
||||
VALUES (%s, %s, %s, %s, %s ,%s ,%s);
|
||||
''', (title, text, link, embedding , similar_d, c_time, True))
|
||||
|
||||
conn.commit()
|
||||
|
||||
@@ -121,6 +122,39 @@ def get_data():
|
||||
cursor.close()
|
||||
return data
|
||||
|
||||
def get_ready_data():
|
||||
conn = psycopg2.connect(
|
||||
host=host,
|
||||
port=port,
|
||||
user=user,
|
||||
password=password,
|
||||
dbname=dbname
|
||||
)
|
||||
cursor = conn.cursor()
|
||||
query = '''SELECT title, text, link, ready FROM vectorsvevijesti WHERE ready = %s;'''
|
||||
|
||||
cursor.execute(query, ('True',))
|
||||
data = cursor.fetchall()
|
||||
cursor.close()
|
||||
return data
|
||||
|
||||
def get_source_data():
|
||||
conn = psycopg2.connect(
|
||||
host=host,
|
||||
port=port,
|
||||
user=user,
|
||||
password=password,
|
||||
dbname=dbname
|
||||
)
|
||||
cursor = conn.cursor()
|
||||
query = '''SELECT title, text, link, ready FROM vectorsvevijesti WHERE ready = %s;'''
|
||||
|
||||
cursor.execute(query, ('False',))
|
||||
data = cursor.fetchall()
|
||||
cursor.close()
|
||||
return data
|
||||
|
||||
|
||||
def modify_similar_data(new_value ,title):
|
||||
|
||||
conn = psycopg2.connect(
|
||||
@@ -138,6 +172,24 @@ def modify_similar_data(new_value ,title):
|
||||
|
||||
conn.commit()
|
||||
|
||||
|
||||
def preparing_articles(new_value ,title):
|
||||
|
||||
conn = psycopg2.connect(
|
||||
host=host,
|
||||
port=port,
|
||||
user=user,
|
||||
password=password,
|
||||
dbname=dbname
|
||||
)
|
||||
cursor = conn.cursor()
|
||||
|
||||
query = '''UPDATE vectorsvevijesti SET ready = %s WHERE title = %s '''
|
||||
|
||||
cursor.execute(query, (new_value, title))
|
||||
|
||||
conn.commit()
|
||||
|
||||
def get_specific_data(title):
|
||||
conn = psycopg2.connect(
|
||||
host=host,
|
||||
@@ -244,7 +296,9 @@ def create_db(conn):
|
||||
link VARCHAR,
|
||||
embedding vector(1536),
|
||||
similar_d VARCHAR,
|
||||
time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
ready BOOLEAN
|
||||
|
||||
);
|
||||
''')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user