-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branches 'main' and 'main' of https://github.com/Moujuruo/AI_Of…
- Loading branch information
Showing
23 changed files
with
21,748 additions
and
2,341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
Flask_Cors==4.0.1 | ||
Flask==2.3.2 | ||
openai | ||
arrow | ||
arrow | ||
qianfan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import hashlib | ||
import sqlite3 | ||
import json | ||
import csv | ||
from sqlite3 import Error | ||
import threading | ||
|
||
db_name = 'Ai_work' | ||
|
||
lock_threading = threading.Lock() | ||
conn = sqlite3.connect(db_name + '.db', check_same_thread=False) | ||
# conn.execute("PRAGMA foreign_keys = ON") # 启用外键支持 | ||
cursor = conn.cursor() | ||
|
||
def createTables(): | ||
# 笔记标题,笔记内容,用户id | ||
cursor.execute('''CREATE TABLE IF NOT EXISTS notes | ||
(note_id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
note_title TEXT NOT NULL, | ||
note_content TEXT, | ||
user_id INTEGER NOT NULL, | ||
FOREIGN KEY (user_id) REFERENCES users(id))''') | ||
conn.commit() | ||
|
||
|
||
createTables() | ||
|
||
def insertNote(note_title, note_content, user_id): | ||
try: | ||
cursor.execute("INSERT INTO notes (note_title, note_content, user_id) VALUES (?, ?, ?)", | ||
(note_title, note_content, user_id)) | ||
conn.commit() | ||
return {"status": 200, "message": "添加成功"} | ||
except Exception as e: | ||
return {"status": 500, "message": f"数据库错误: {e}"} | ||
|
||
def updateNote(note_title, note_content, user_id): | ||
try: | ||
cursor.execute("UPDATE notes SET note_content = ? WHERE note_title = ? AND user_id = ?", | ||
(note_content, note_title, user_id)) | ||
conn.commit() | ||
return {"status": 200, "message": "更新成功"} | ||
except Exception as e: | ||
return {"status": 500, "message": f"数据库错误: {e}"} | ||
|
||
def getNoteByTitle(note_title, user_id): | ||
cursor.execute("SELECT * FROM notes WHERE note_title = ? AND user_id = ?", (note_title, user_id)) | ||
note = cursor.fetchone() | ||
if note is None: | ||
return False | ||
else: | ||
return True | ||
|
||
def getNoteTitleList(user_id): | ||
cursor.execute("SELECT note_title FROM notes WHERE user_id = ?", (user_id,)) | ||
notes = cursor.fetchall() | ||
return notes | ||
|
||
def getNoteContent(userid, title): | ||
cursor.execute("SELECT note_content FROM notes WHERE user_id = ? AND note_title = ?", (userid, title)) | ||
note = cursor.fetchone() | ||
print(note) | ||
return note | ||
|
||
def deleteNoteByTitle(user_id, note_title): | ||
cursor.execute("DELETE FROM notes WHERE note_title = ? AND user_id = ?", (note_title, user_id)) | ||
conn.commit() | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
DANGEROUSLY_DISABLE_HOST_CHECK=true | ||
DANGEROUSLY_DISABLE_HOST_CHECK=true | ||
PUBLIC_URL=. |
Oops, something went wrong.