我有一个小问题.我启动我的应用程序,并在启动查询并比较后rs == null得到错误ResultSet is closed.
这是代码:
error_code = NO_ERROR;
try
{
ArrayList <Harmonogram> al = new ArrayList <Harmonogram> ();
ResultSet rs = stat.executeQuery(myQuery);
if (rs == null)
{
return null;
}else{
Harmonogram harm = new Harmonogram(rs.getLong(1), rs.getInt(2), rs.getInt(3), rs.getInt(4), rs.getLong(5), rs.getString(6));
Run Code Online (Sandbox Code Playgroud)
在此之后我得SQLException告诉我:ResultSet is closed.
我遇到了这个我无法解决的错误我在Python中使用tkinter接口编写一些代码来将数据从文本文件传输到sqlite.
首先,这是相关代码:
def submit_data(self):
self.new_filename = self.file_entry.get()
self.new_tablename = self.table_entry.get()
self.new_fieldname = self.field_entry.get().split(',')
#print(self.new_fieldname)
self.create_new.destroy()
from sqlite3 import dbapi2 as sqlite
con = sqlite.connect(self.new_filename)
cur = con.cursor()
cur.execute('CREATE TABLE ' + self.new_tablename + '(id INTEGER PRIMARY KEY)')
for field in self.new_fieldname:
cur.execute('ALTER TABLE ' + self.new_tablename + ' ADD ' + field)
with open(self.filename, 'r', encoding='latin-1') as self.the_file:
status = True
#_keynumber=1
while status:
_row = self._next_line()
if _row:
_entry_list = _row.split(',')
# add space after text line comma for …Run Code Online (Sandbox Code Playgroud) 我想在我的iPhone应用程序中使用fmdb.使用sqlite和没有fmdb的fmdb有什么区别?
我需要能够编写查询.
fmdb如何比单个sqlite更容易/有效使用?如果有任何源代码或指南,请发布其链接
我正在尝试查询sqlite android以查看例如表中存在给定用户名的用户数量.这是我的功能.我必须指定"getContentResolver()!= null",因此是变量名.
private int findSelectedUser(String name) {
int count = 0;
try {
String[] whereArgs = new String[] {name};
String[] PROJECTION = new String[] { MyProvider.SETTINGS_USERNAME };
Cursor c = getContentResolver().query(MyProvider.SETTINGS_URI,
PROJECTION, MyProvider.SETTINGS_USERNAME , whereArgs, null);
if (c != null) {
count = c.getCount();
c.close();
}
} catch (NullPointerException e) {
}
System.out.println("Found something? " + count);
return count;
}
Run Code Online (Sandbox Code Playgroud)
跑完后我收到了主题的错误......并且没有得到它.在我的where子句中,我有一列,在我的where参数中有一个值.请帮我看一下这个,谢谢.
是否有推荐的SQLite免费Mac OSX IDE?我从2009年和2010年看到了SO的一些答案,但最近没有.如果Firefox的SQLite管理器仍然是最好的,那么我会尝试一下.我只是想知道自那时以来是否还有其他事情让人们更喜欢.在功能方面我没有具体要求,只是一个可靠,用户友好,尽可能全功能的工具.
I'm writing some code here, and I'm having a had time.
I have a value in my Database that can be null as its an average of other data, if that data hasn't been populated there is nothing to take the average of.
In my query there will return a null value at times. The value that would be there normally is a double. SO i have
NSNumber *num = [NSNumber numberWithDouble:sqlite3_column_double(compiledStatement,7)];
if (num == nil) {
do something
} …Run Code Online (Sandbox Code Playgroud) 在websql中,我们可以像这样请求某一行:
tx.executeSql('SELECT * FROM tblSettings where id = ?', [id], function(tx, rs){
// do stuff with the resultset.
},
function errorHandler(tx, e){
// do something upon error.
console.warn('SQL Error: ', e);
});
Run Code Online (Sandbox Code Playgroud)
但是,我知道常规的SQL,并认为我应该能够请求
var arr = [1, 2, 3];
tx.executeSql('SELECT * FROM tblSettings where id in (?)', [arr], function(tx, rs){
// do stuff with the resultset.
},
function errorHandler(tx, e){
// do something upon error.
console.warn('SQL Error: ', e);
});
Run Code Online (Sandbox Code Playgroud)
但这没有给我们任何结果,结果总是空的.如果我将删除[arr]入arr,然后sql将获得可变数量的参数,所以我认为它应该是[arr].否则它将要求我们添加动态数量的问号(与数组中的id一样多).
那么有谁能看到我做错了什么?
NSString *query = [[NSString alloc] initWithFormat:@"SELECT * FROM objects ", catIdS];
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(database, [query UTF8String], -1, &statement, nil) == SQLITE_OK) {
while (sqlite3_step(statement) == SQLITE_ROW) {
char *nameChar = sqlite3_column_text(statement, 1);
NSString *title = [[NSString alloc] initWithUTF8String:nameChar];
}
sqlite3_finalize(statement);
}
Run Code Online (Sandbox Code Playgroud)
语义问题"使用类型为const的表达式初始化char*丢弃限定符"在行中 char *nameChar = sqlite3_column_text(statement, 1)
如果更改char *nameChar为char *nameChar
语义问题"将unsigned char*发送到const char*类型的参数"将指针转换为具有不同符号的整数类型
我根据教程在 python 中创建了一个 sqlite 数据库:
from sqlalchemy import create_engine
engine = create_engine('sqlite:///DB.db')
Run Code Online (Sandbox Code Playgroud)
下次我运行 python 脚本时,它里面有旧数据。
如何删除所有行、重新初始化甚至删除数据库(它位于哪里?)?
我正在尝试从 SQLite 数据库中检索最近 7 天的记录。我有一个考勤系统,我试图在用户界面上显示一些统计数据,但目前它不起作用 - 我将在下面显示我当前的代码。
楷模:
class Meta:
model = User
fields = ("username", 'email', 'password1', 'password2')
class is_Present(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
date = models.DateField(default=datetime.date.today)
is_present = models.BooleanField(default=False)
class clocked_Time(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
date = models.DateField(default=datetime.date.today)
time = models.DateTimeField(null=True, blank=True)
signed_out = models.BooleanField(default=False)
Run Code Online (Sandbox Code Playgroud)
视图.py:
# Get Count of Present Employees in last week
def present_week_employees():
today = date.today()
week = today - timedelta(days=7)
present_employees_all = is_Present.objects.filter(date=week).filter(is_present=True)
return len(present_employees_all)
# Displays admin attendance portal functions
def attendance_portal(request): …Run Code Online (Sandbox Code Playgroud)