You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.5 KiB
58 lines
1.5 KiB
import os
|
|
import sqlite3
|
|
import sys
|
|
|
|
sys.path.append(os.path.join(os.path.abspath(__file__).split('AlphaGenerator')[0] + 'AlphaGenerator'))
|
|
PROJECT_PATH = os.path.join(os.path.abspath(__file__).split('AlphaGenerator')[0] + 'AlphaGenerator')
|
|
PREPARE_PROMPT = os.path.join(str(PROJECT_PATH), 'prepare_prompt')
|
|
|
|
input_alpha = 'not(is_nan({}))'
|
|
|
|
# 数据库搜索字段
|
|
REGION = 'USA'
|
|
UNIVERSE = 'TOP3000'
|
|
TARGET = 'pv87_%'
|
|
|
|
|
|
def sqliteLoader(file_path):
|
|
if not os.path.exists(file_path):
|
|
print(f"SQLite数据库文件不存在: {file_path}")
|
|
exit(1)
|
|
|
|
conn = sqlite3.connect(file_path)
|
|
try:
|
|
|
|
cursor = conn.cursor()
|
|
|
|
# 首先筛选符合 region 和 universe 条件的数据
|
|
cursor.execute("SELECT name FROM data_sets WHERE region=? AND universe=? AND name like ?",
|
|
(REGION, UNIVERSE, TARGET))
|
|
rows = cursor.fetchall()
|
|
|
|
conn.close()
|
|
|
|
if len(rows) > 0:
|
|
print(f"找到 {len(rows)} 条符合条件的数据")
|
|
return rows
|
|
else:
|
|
print("未找到符合条件的数据")
|
|
exit(1)
|
|
|
|
except sqlite3.Error as e:
|
|
print(f"SQLite数据库错误: {e}")
|
|
exit(1)
|
|
finally:
|
|
if conn:
|
|
conn.close()
|
|
|
|
data_sets_path = os.path.join(PREPARE_PROMPT, "data_sets.db")
|
|
data_rows = sqliteLoader(data_sets_path)
|
|
|
|
start_at = 0
|
|
end_at = 1000
|
|
|
|
for num in range(start_at, end_at):
|
|
row = data_rows[num]
|
|
new_alpha = input_alpha.format(row[0])
|
|
print(new_alpha)
|
|
|
|
|