1.
@yingshaoxo,你要给/var/www/html/db
文件夹写入权限(chmod 0777 /var/www/html/db
)。不过其实程序早就不支持sqlite了,因为我后来写了很多MySQL专属语法,用sqlite肯定会报SQL语法错误,你得自己改。
2.
此外,这里有支持php 8.1的版本。注意:不支持php 8.2。
https://github.com/hu60t/hu60wap6
数据库必须使用mysql或者与之兼容的mariadb等分支。
3.
@yingshaoxo,docker 拉取镜像时指定版本号,就能固定版本了吧
网络设置也不麻烦吧,实在不行用 host 模式?性能损耗也更少些?
4.
@老虎会游泳,
谢谢,改了db folder permission后,原错误确实消失了。
后来我自己建了一个新的sqlite的db文件,现在主页可以访问了:
https://gitlab.com/yingshaoxo/tiger_bbs_php5.4.45/-/blob/main/db/sqlite.sql_command?ref_type=headshttps://gitlab.com/yingshaoxo/tiger_bbs_php5.4.45/-/blob/main/db/test.db3?ref_type=heads但无法注册用户,会报错。
新的错误:
错误代码:22
错误信息:数据库写入错误,SQL预处理失败。
错误发生在 /var/www/html/class/user.php 的第 416 行
错误追踪信息:
#0 /var/www/html/page/user/reg.php(30): user->reg('yingshaoxo', 'password', 'yingshaoxo
@gmai...')
#1 /var/www/html/q.php(74): include('/var/www/html/p...')
#2 {main}
$rs = $db->prepare('SELECT `active`,`uid`,`name`,`mail`,`sid`,`sidtime`,`regtime`,`acctime`' . ($getinfo ? ',`info`' : '') . ' FROM `' . DB_A . 'user` WHERE `sid`=?');
$x_getinfo = $getinfo;
}
if (!$rs || !$rs->execute(array($sid))) throw new PDOException('数据库查询失败,SQL' . ($rs ? '执行' : '预处理') . '失败。', $rs ? 21 : 22);
$data = $rs->fetch(db::ass);
______
> 以下不是重点:
我不太懂php的程序,感觉编译器太难固定了,我之前找到一个5.7MB的x86_linux静态编译的Python3.2程序,感觉就挺好用:
https://gitlab.com/yingshaoxo/yingshaoxo_alpine_x86_system/-/blob/main/python?ref_type=heads我感觉如果我有时间的话,都想用python重写一遍简单的wap论坛了,完全脱离docker,sql,javascript,php,就简单的自实现的http server + file read/write + html + css
6.
@无名啊,
1. 全文搜索不是事儿
2. 增量备份没必要,一般纯文本的数据不会超过3GB
3. 一天备份一次
4. 服务器程序一般不会断电
5. SSD的速度很快了,人类几乎没有延时感。同时纯文本要做memory dict cache,保存最近访问的1000个文章,快如闪电。
我之前用Python写过类似的数据库,只不过没写中心化的pipe line,多进程会出问题:
https://github.com/yingshaoxo/auto_everything/blob/dev/auto_everything/database.py#L357其中一点代码:
“”“
if self.use_sqlite == False:
self.database_txt_file_path = self._disk.join_paths(self.database_base_folder, f"{self.database_name}.txt")
if (not self._disk.exists(self.database_txt_file_path)):
self._io.write(self.database_txt_file_path, "")
”“”
“”“
def raw_search(self, one_row_json_string_handler: Callable[[str], dict[str, Any] | None]) -> Iterator[dict[str, Any]]:
"""
one_row_json_string_handler: a_function to handle search process. If it returns None, we'll ignore it, otherwise, we'll add the return value into the result list.
```
def one_row_json_string_handler(item: str) -> dict[str, Any] | None:
return json.loads(item)
#return None
```
"""
if self.global_multiprocessing_shared_dict != None:
self._wait_until_unlock()
self.global_multiprocessing_shared_dict[self._the_key_for_the_lock_of_memory_data] = True
for row in self.global_multiprocessing_shared_dict[self._the_key_for_memory_data]:
json_string = self._json.dumps(row, sort_keys=True).strip()
result = one_row_json_string_handler(json_string)
if (result != None):
yield result
self.global_multiprocessing_shared_dict[self._the_key_for_the_lock_of_memory_data] = False
return
if self.use_sqlite:
for row in self.sql_cursor.execute(
f"SELECT * FROM {self._sql_table_name}"
):
result = one_row_json_string_handler(row[0])
if (result != None):
yield result
else:
with open(self.database_txt_file_path, "r") as file_stream:
previous_position = None
while True:
current_position = file_stream.tell()
line = file_stream.readline()
if previous_position == current_position:
# reach the end
break
previous_position = current_position
if (line.strip() == ""):
# ignore empty line
continue
if (line.startswith('#')):
# ignore deleted line
continue
result = one_row_json_string_handler(line)
if (result != None):
yield result
”“”
7.
@yingshaoxo,
之前用mysql的时候,安装需要导入一个sql的命令文本文件,来实现table的建立。但现在换成sqlite,难道只能手工建表了吗
或者你把mysql的建表语句修改为兼容sqlite然后写一个程序去执行这些sql就能自动建出来了。
从我切换到mysql以来,后续所有涉及数据库的代码修改都没有考虑sqlite兼容性,所以这个sqlite连接功能其实基本不能用,只是还没从代码里删掉而已。
8.
@yingshaoxo,你是说,帖子放内存里,就不会慢了,是吧。。
- 单线程提供服务,并发量会不会很低。。
- 多线程数据同步,会不会很麻烦?
- 啥时候落盘一次数据呢?此时整个服务都要卡住吗。。
- 后续扩展功能,会不会还不如写
SQL
方便。。