sqlite字节到sqlite文件

发布于 2025-01-27 23:06:47 字数 688 浏览 3 评论 0原文

我有一个.sqlite文件,该文件已转换为字节格式,我想知道如何将其转换为一个格式,我可以在其中操纵其中的数据以及读取。

该代码在Python中,数据库在SQLite中。

任何事情都有用!想有一个方向。

b'SQLite format 3\x00\x10\x00\x01\x01\x00@  \x00\x04\xa4\xb2\x00\x00\x0f\xed\x00\x00\x04~\x00\x00\x00\x18\x00\x00\x002\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\xa4\xb2\x00.S`\x05\x00\x00\x00\x0b\x0f\xc9\x00\x00\x00\x08F\x0f\xfb\x0f\xf6\x0f\xf1\x0f\xec\x0f\xe7\x0f\xe2\x0f\xdd\x0f\xd8\x0f\xd3\x0f\xce\x0f\xc9\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x

I have a .sqlite file that was converted into a byte format, I would like to know how to convert it to a format where I can manipulate the data inside of it, as well as read.

The code is in python and the database is in sqlite.

Anything is helpful! Would like to have a direction to go.

b'SQLite format 3\x00\x10\x00\x01\x01\x00@  \x00\x04\xa4\xb2\x00\x00\x0f\xed\x00\x00\x04~\x00\x00\x00\x18\x00\x00\x002\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\xa4\xb2\x00.S`\x05\x00\x00\x00\x0b\x0f\xc9\x00\x00\x00\x08F\x0f\xfb\x0f\xf6\x0f\xf1\x0f\xec\x0f\xe7\x0f\xe2\x0f\xdd\x0f\xd8\x0f\xd3\x0f\xce\x0f\xc9\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泅人 2025-02-03 23:06:47

如果只是原始字节,您应该能够将其保存到文件:

1。准备一些数据
$ sqlite3 test.sqlite
SQLite version 3.36.0 2021-06-18 18:36:39
Enter ".help" for usage hints.
sqlite> CREATE TABLE t1 (c1 INT);
sqlite> INSERT INTO t1 VALUES (1);
sqlite> SELECT * FROM t1;
1
sqlite> .quit
2。从字节创建一个新的DB文件:
>>> db = bytes(open("test.sqlite", "rb").read())
>>> db[:20]
b'SQLite format 3\x00\x10\x00\x01\x01'
>>> open("new.sqlite", "wb").write(db)
8192
3。test。
>>> import sqlite3
>>> con = sqlite3.connect("new.sqlite")
>>> cur = con.cursor()
>>> for row in cur.execute("SELECT * FROM t1"): print(row)
... 
(1,)

If that's just raw bytes you should be able to save it to a file:

1. Prepare some data
$ sqlite3 test.sqlite
SQLite version 3.36.0 2021-06-18 18:36:39
Enter ".help" for usage hints.
sqlite> CREATE TABLE t1 (c1 INT);
sqlite> INSERT INTO t1 VALUES (1);
sqlite> SELECT * FROM t1;
1
sqlite> .quit
2. Create a new DB file from bytes:
>>> db = bytes(open("test.sqlite", "rb").read())
>>> db[:20]
b'SQLite format 3\x00\x10\x00\x01\x01'
>>> open("new.sqlite", "wb").write(db)
8192
3. Test
>>> import sqlite3
>>> con = sqlite3.connect("new.sqlite")
>>> cur = con.cursor()
>>> for row in cur.execute("SELECT * FROM t1"): print(row)
... 
(1,)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文