轻松地存储关于SQLite数据库的元数据 [英] Easy way to store metadata about SQLite Database
问题描述
我想知道是否有一个简单的方法来存储该数据库中的sqlite-Database的元信息。
I was wondering if there is a simple way to store meta information about an sqlite-Database in that database.
我具体考虑一个版本号,你很容易找到你使用的数据库布局的版本(所以我的代码可以检查数据库结构是否兼容,而不查询 SELECT sql FROM sqlite_master WHERE type ='table';
并将结果与预定义原理图进行比较)。澄清:我不是对sqlite软件的版本号感兴趣,但类似于pythons __ version __
变量,可以分别为每个python文件。
I am specifically thinking about a version number that lets you easily find out which version of a database layout you are using (So my code could check if the database structure is compatible without querying SELECT sql FROM sqlite_master WHERE type='table';
and comparing the result with a predefined schematic). To clarify: I am not interested in the version number of the sqlite software, but something akin to pythons __version__
variable that can be defined seperately for each python file.
我知道我可能只是创建一个名为meta的表并将其保存在那里,但我想知道是否有更好的方法。
I know that I can probably just create a table named "meta" and save it there, but I was wondering if there was a better way to do that.
我也知道,只通过检查版本号检查兼容性有一些问题,如果必要,我还会做其他检查,但现在我只感兴趣
I also know that checking compatibility by only checking a version number has some problems, and I will still do other checks if necessary, but for now I am only interested in the version number I described.
推荐答案
您可能想查看 user_version pragma 。
这篇关于轻松地存储关于SQLite数据库的元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!