sqlite

How do I select rows from table?

◇◆丶佛笑我妖孽 提交于 2020-12-26 11:24:09
问题 I'm making an app where MainActivity has a RecyclerView that contains the user's lists e.g. grocery list, weekly list, etc. When the user clicks on an item, it'll navigate to products activity also has a RecyclerView. I have 2 different SQLite databases 1:lists 2:products. The logic I used is when a user adds a list, the lists database will record list name and id, also adds list name in products database, and when user add product, I used update() instead of insert() in SQLite because the

How to execute SELECT * LIKE statement with a placeholder in sqlite?

给你一囗甜甜゛ 提交于 2020-12-26 07:13:09
问题 I've got an argument tag and I perfomed this way: cursor.execute("SELECT * FROM posts WHERE tags LIKE '%?%'", (tag,)) but it doesn't seem to work. I'm new to sqlite, please tell me how to fix it. Thx ! 回答1: Apply the wildcards to the parameter, not the SQL: cursor.execute("SELECT * FROM posts WHERE tags LIKE ?", (f'%{tag}%',)) The ? SQL parameter interpolation adds quoting for you, so your query ends up as '%'value'%' , which is not valid SQL. 回答2: Remove the % : cursor.execute("SELECT * FROM

How to execute SELECT * LIKE statement with a placeholder in sqlite?

风流意气都作罢 提交于 2020-12-26 07:12:20
问题 I've got an argument tag and I perfomed this way: cursor.execute("SELECT * FROM posts WHERE tags LIKE '%?%'", (tag,)) but it doesn't seem to work. I'm new to sqlite, please tell me how to fix it. Thx ! 回答1: Apply the wildcards to the parameter, not the SQL: cursor.execute("SELECT * FROM posts WHERE tags LIKE ?", (f'%{tag}%',)) The ? SQL parameter interpolation adds quoting for you, so your query ends up as '%'value'%' , which is not valid SQL. 回答2: Remove the % : cursor.execute("SELECT * FROM

How to execute SELECT * LIKE statement with a placeholder in sqlite?

可紊 提交于 2020-12-26 07:12:03
问题 I've got an argument tag and I perfomed this way: cursor.execute("SELECT * FROM posts WHERE tags LIKE '%?%'", (tag,)) but it doesn't seem to work. I'm new to sqlite, please tell me how to fix it. Thx ! 回答1: Apply the wildcards to the parameter, not the SQL: cursor.execute("SELECT * FROM posts WHERE tags LIKE ?", (f'%{tag}%',)) The ? SQL parameter interpolation adds quoting for you, so your query ends up as '%'value'%' , which is not valid SQL. 回答2: Remove the % : cursor.execute("SELECT * FROM

How to execute SELECT * LIKE statement with a placeholder in sqlite?

人走茶凉 提交于 2020-12-26 07:11:10
问题 I've got an argument tag and I perfomed this way: cursor.execute("SELECT * FROM posts WHERE tags LIKE '%?%'", (tag,)) but it doesn't seem to work. I'm new to sqlite, please tell me how to fix it. Thx ! 回答1: Apply the wildcards to the parameter, not the SQL: cursor.execute("SELECT * FROM posts WHERE tags LIKE ?", (f'%{tag}%',)) The ? SQL parameter interpolation adds quoting for you, so your query ends up as '%'value'%' , which is not valid SQL. 回答2: Remove the % : cursor.execute("SELECT * FROM

Calling Async method in class constructor in C# [duplicate]

岁酱吖の 提交于 2020-12-26 04:01:01
问题 This question already has answers here : Can constructors be async? (12 answers) Closed 5 years ago . Currently I'm developing an universal app using c#. In app I used sqlite as database and as you may now It has async methods. I have a class with some null property that I'll fill them using data I fetch from db, but It should be done exactly in class constructor. The problem is that using async methods is not allowed, So I tried creating a new async method and using sqlite methods and

Calling Async method in class constructor in C# [duplicate]

淺唱寂寞╮ 提交于 2020-12-26 03:59:21
问题 This question already has answers here : Can constructors be async? (12 answers) Closed 5 years ago . Currently I'm developing an universal app using c#. In app I used sqlite as database and as you may now It has async methods. I have a class with some null property that I'll fill them using data I fetch from db, but It should be done exactly in class constructor. The problem is that using async methods is not allowed, So I tried creating a new async method and using sqlite methods and

sqlite query to get all list of table names with number of records in it

我的未来我决定 提交于 2020-12-26 03:43:12
问题 Please help on below query : sqlite query to get all list of table names with number of records in it : I want to get the count of rows in every table in a Sqlite3 database. I want to avoid writing out a longhand query. I can get the list of tables like this: SELECT name FROM sqlite_master WHERE type='table' and I would like to use it in a subquery like this: select count (*) from (SELECT name FROM sqlite_master WHERE type='table'); but would just return the total rows in the subquery, which

Python - SqlAlchemy: Filter query by great circle distance?

安稳与你 提交于 2020-12-25 05:19:57
问题 I am using Python and Sqlalchemy to store latitude and longitude values in a Sqlite database. I have created a hybrid method for my Location object, @hybrid_method def great_circle_distance(self, other): """ Tries to calculate the great circle distance between the two locations If it succeeds, it will return the great-circle distance multiplied by 3959, which calculates the distance in miles. If it cannot, it will return None. """ return math.acos( self.cos_rad_lat * other.cos_rad_lat * math

Upgrading SQLite3 version used in python3 on linux?

浪尽此生 提交于 2020-12-25 04:29:38
问题 I need to upgrade the sqlite3 version that my python 3 uses but there seems to be no clear answers and I don't understand what determines the version of sqlite3 used by python. I am running CentOS7 with python 3.6.4 installed. CentOS had sqlite version 3.7.17 installed and I upgraded this to 3.23.1 thinking python would also use this never version of sqlite. import sqlite3 print(sqlite3.sqlite_version) The following code still gives me 3.17. I have googled how to upgrade the version but most