Sqlite判断字段存在
判断表存在的方法很简单,网上很多:
SELECT COUNT(*) from sqlite_master where type='table' and name='%s'" % tname;
那么判断字段是否存在, 或者说如何判断表的版本是否最新就只需要:
select * from sqlite_master where tbl_name='tblContactList';
sqlite_master 的表结构如下:
type |name |tbl_name |rootpage |sql
最后一个sql就是创建tblContactList表的sql语句, 所以只要判断这个sql语句是否和你的创建语句一样就可以知道该表是不是你最新的版本.
相关文档:
我现在要使用SQLite3.0创建一个数据库,然后在数据库中创建一个表格。
首先要引入SQLite3.0的lib库。然后包含头文件#import <sqlite3.h>
【1】打开数据库,如果没有,那么创建一个
sqlite3* database_;
-(BOOL) open{
NSArray *paths = NSSearchPathForDirectoriesInDomai ......
QT读写Sqlite数据库
//.h
/****************************************************************************
**
** Date : 2010-05-08
** Author : furtherchan
** If you have any questions , please contact me
**
****************************************************************** ......
代码很乱,而且没有用到模板,把html代码跟Python代码混在一起了,而且也没有用到web.py本身提供的数据库操作模块,绝对粗超的代码!
学习了很多东西,首先当然是web.py,然后是sqlite,接下来是time模块——看来也唯有不断的实践,才真正能进步!
说实在的,偶学html到现在这么久,还是半桶水,悲剧了!
01&n ......
1 TOP
这是一个大家经常问到的问题,例如在SQLSERVER中可以使用如下语句来取得记录集中的前十条记录:
SELECT TOP 10 * from [index] ORDER BY indexid DESC;
但是这条SQL语句在SQLite中是无法执行的,应该改为:
SELECT * from [index] ORDER BY indexid DESC limit 0,10;
其中limit 0,10表示从第0 ......
1:定义表的结构和名字,我使用以下方法:
public interface Constatnts extends BaseColumns {
public static final String TABLE_NAME = "test";
public static final String TIME = "time";
public static final String TITLE = "title";
}
在这里,我继承 ......