sqlite

When I changed the device language, app crashes

橙三吉。 提交于 2020-04-17 22:57:50
问题 I used SQLite and in my project it works well if the device language is in English. However if I change the device language I get an error which is; java.lang.IllegalArgumentException: the bind value at index 1 is null .... com.radioapps.radiostations2020.models.DatabaseHelper.getRadioNamesByCountryName(DatabaseHelper.java:127) line 127 is; Cursor c = myDataBase.rawQuery(query, new String[]{string}); and the whole method is; public List<String> getRadioNamesByCountryName(String string) { List

When I changed the device language, app crashes

大兔子大兔子 提交于 2020-04-17 22:56:40
问题 I used SQLite and in my project it works well if the device language is in English. However if I change the device language I get an error which is; java.lang.IllegalArgumentException: the bind value at index 1 is null .... com.radioapps.radiostations2020.models.DatabaseHelper.getRadioNamesByCountryName(DatabaseHelper.java:127) line 127 is; Cursor c = myDataBase.rawQuery(query, new String[]{string}); and the whole method is; public List<String> getRadioNamesByCountryName(String string) { List

Passing in a string to use as part of a Room query

房东的猫 提交于 2020-04-17 22:50:26
问题 Why does this not work in Room?: val dataSourceFactory = database.gameDao.getGames("Game.platforms LIKE '%XONE%'") @Query("SELECT * FROM Game WHERE :likeClause") fun getGames(likeClause: String): DataSource.Factory<Int, Game> But this does?: @Query("SELECT * FROM Game WHERE Game.platforms LIKE '%XONE%'") fun getGames(): DataSource.Factory<Int, Game> Is there any way to pass in a string that can stand in as part of the query? EDIT: I know this isn't the correct way to form a single LIKE clause

Passing in a string to use as part of a Room query

笑着哭i 提交于 2020-04-17 22:42:50
问题 Why does this not work in Room?: val dataSourceFactory = database.gameDao.getGames("Game.platforms LIKE '%XONE%'") @Query("SELECT * FROM Game WHERE :likeClause") fun getGames(likeClause: String): DataSource.Factory<Int, Game> But this does?: @Query("SELECT * FROM Game WHERE Game.platforms LIKE '%XONE%'") fun getGames(): DataSource.Factory<Int, Game> Is there any way to pass in a string that can stand in as part of the query? EDIT: I know this isn't the correct way to form a single LIKE clause

Promise.then() firing on SequelizeUniqueConstraintError

别等时光非礼了梦想. 提交于 2020-04-17 22:18:09
问题 I am a little new to promises and Sequelize. I am trying to insert a new user to my SQLite-database using constraint. In the User -model I have flagged the email -property as unique , however when this constraint is not met the code inside the .then() -block is still executed. Code: User.create({ email: uname, password: psw }) .then(console.log('success')) .catch((err) => { console.log(err); }); Output: Success Executing (default): INSERT INTO `users` ... { SequelizeUniqueConstraintError:

Android用SQLite存储数据详解

被刻印的时光 ゝ 提交于 2020-04-17 04:08:11
【推荐阅读】微服务还能火多久?>>> Android为了让我们能够更加方便地管理数据库,专门提供了一个SQLiteOpenHelper帮助 类,借助这个类就可以经常简单地对数据库进⾏创建和升级。既然有好东西可以直接使用,那 我们当然要尝试一下了,下面我就将对SQLiteOpenHelper的基本用法进行介绍。 瘦先你要知道SQLiteOpenHelper是一个抽象类,这意味着如果我们想要使用它的话,就需要创建一个自己的帮助类去继承它。 SQLiteOpenHelper中有两个抽象方法,分别是onCreate()和onUpgrade(),我们必须在自己的帮助类里面重写这两个方法,然后分别在这两个方法中去实现创建、升级数据库的逻辑。SQLiteOpenHelper 中 还 有 两 个 非 常 重 要 的 实 例方 法 , getReadableDatabase() 和getWritableDatabase()。这两个方法都可以创建或打开一个现有的数据库(如果数据库已存在则直接打开,否则创建一个新的数据库),并返回一个可对数据库进行读写操作的对象。不同的是,当数据库不可写入的时候(如磁盘空间已满) getReadableDatabase()方法返回的对象将以只读的方式去打开数据库,而getWritableDatabase()方法则将出现异常

开源中国 OsChina Android 客户端源码分析(8)数据库Sqlite

走远了吗. 提交于 2020-04-17 04:07:45
【推荐阅读】微服务还能火多久?>>> 1开源中国客户端使用的数据库部分的源码在net.oschina.app.db包下,两个类一个是用于管理数据库的创建类DatabaseHelper,继承SQLiteOpenHelper,另一个是用于数据库的增删改查的工具类 NoteDatabase 。那么数据库在开源中国源码中哪一模块用到了呢? 便签管理,便签是什么?就是一个记事本的功能o(^▽^)o 2关于 SQLiteOpenHelper的使用,自己之前的项目中没有用到过,看了下,这里有个体会:当获取到 SQLiteOpenHelper实例,并使用getWritableDatabase或者getReadableDatabase打开数据库时,如果数据库没有建立,则建立数据库,并回调oncreate方法,那么数据库建立好了,我们就可以在oncreate方法里完成数据表的建立或者数据的初始化。 3既然要创建数据库,那么数据库的名字,初始化建立的表,版本号这些参数,就需要在 SQLiteOpen Helper类中声明。 4在 数据库的增删改查的工具类 NoteDatabase中,我们发现采用了组合的方式,在其构造函数中完成了 SQLiteOpen Helper实例化,这样在内部声明的方法中,我们就可以直接使用 SQLiteOpen

DataAnalysis-读取本地数据

梦想的初衷 提交于 2020-04-16 09:54:02
【推荐阅读】微服务还能火多久?>>> 一、TXT文件操作 读取全部内容 import numpy as np import pandas as pd txt_filename = './files/python_wiki.txt' # 打开文件 file_obj = open(txt_filename,'r') # 读取整个文件内容 all_content = file_obj.read() # 关闭文件 file_obj.close() print (all_content) Python is a widely used high-level, general-purpose, interpreted, dynamic programming language.[24][25] Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than possible in languages such as C++ or Java.[26][27] The language provides constructs intended to enable writing clear

Microsoft.Data.Sqlite.SqliteException: 'SQLite Error 14: 'unable to open database file'.'

给你一囗甜甜゛ 提交于 2020-04-16 05:49:12
问题 I get this error Microsoft.Data.Sqlite.SqliteException: 'SQLite Error 14: 'unable to open database file'.' when I try to run this code, it is a UWP application and I am using sqlite private void btnContinue_Click(object sender, RoutedEventArgs e) { string datasource = @"F:\Curtis\Documents\Capstone\Capstone\Database\BobDB.db"; ; using (SqliteConnection conn = new SqliteConnection(@"Data Source = " + datasource)) { conn.Open(); SqliteCommand command = conn.CreateCommand(); command.CommandText

SQLite: How to achive RANDOM ORDER and pageintation at the same time?

走远了吗. 提交于 2020-04-16 05:15:12
问题 I have a table of movies, I want to be able to query the database and get a randomized list of movies, but also I don't want it to return all movies available so I'm using LIMIT and OFFSET . The problem is when I'm doing something like this: SELECT * FROM Movie ORDER BY RANDOM() LIMIT 50 OFFSET 0 and then when querying for the next page with LIMIT 50 OFFSET 50 the RANDOM seed changes and so it's possible for rows from the first page to be included in the second page, which is not the desired