Click here to Skip to main content
15,891,597 members
Everything / Sqlite

Sqlite

SQLite

Great Reads

by Thomas Weller
Demonstrates how to run Python scripts from C#
by DaveMathews
Use Oscova, a bot development framework, to create a Natural Language Interface to an SQL Database
by Glenn Prince
In this second part of the Data Cleaning with Python and Pandas series, now that we have a Jupyter Notebook set up and some basic libraries initialized, we need to load some data. To do this, we’ll load data from a CSV file, as well as from a local SQLite database.
by Hein Pauwelyn
This is an application made for Windows (Universal) 10 devices made with MVVM, IoC-containers and dependency injection. There is also an API from Yahoo and SQLite service.

Latest Articles

by Zijian
Reusable codes for JWT security in business applications
by Mircea Neacsu
Examines the performance of SQLite in multi-threading applications
by Member 4206974
A PHP class that uses PDO for creating a table from JSON Objects
by JBartlau
This article demonstrates how Report Server offers a distribution of reports that save time, increase efficiency, and reduce potential errors.

All Articles

Sort by Updated

Sqlite 

N 26 Apr 2024 by OriginalGriff
The most likely solution is that the WHERE clause failed: either use the debugger or add logging code to find out exactly what is in selected_item when that code executes, and compare it against the actual DB content. Unless they match exactly no...
N 26 Apr 2024 by Member 15783420
I have created a custom tkinter app and allow the user to update their data. Even thought the message popup the Record Updated, but the SQLite database seem did not change. Where am I go wrong? How am I fix it? What I have tried: def update(): ...
N 23 Apr 2024 by Member 14770314
This only addresses code behind code. There is no solution for event handler or command handler that lives in a databound ViewModel. No solution for that. It forces code behind and not View Model implementation, or at least a partial mvvm solution.
17 Apr 2024 by Zijian
Reusable codes for JWT security in business applications
3 Apr 2024 by Member 15783420
row_id = content.lastrowid new_row_values = [row_id, my_name, my_class, my_mark, my_gender, my_hostel, my_address] table.add_row(new_row_values)
2 Apr 2024 by Richard MacCutchan
You have your parameters in the wrong order in the call to add_row as shown in the source code at CTkTable/CTkTable/ctktable.py at main · Akascape/CTkTable · GitHub[^]: table.add_row(END, my_data) The data dictionary must be the...
2 Apr 2024 by Pete O'Hanlon
You shouldn't need to specify END in add_row. As far as I can tell, from the documentation, you should be able to do this to add the data to the end.table.add_row(my_data) Having looked at your code, you're trying to add a dictionary to something...
2 Apr 2024 by Member 15783420
I need to create a Custom Tkinter app with CTK table, I have an errored when I insert data. I want to insert the data at the end of each row of table, but I didn't know what is the row number should be. My code is as below: What I have tried: ...
26 Mar 2024 by Member 15783420
sql = "INSERT INTO student_address (name, class, mark, gender, address, hostel) \ VALUES(:name, :class, :mark, :gender, :address, :hostel)" my_data = { "name": my_name, "class":...
25 Mar 2024 by Pete O'Hanlon
The problem appears to be that you are relying on positional placement of your parameters, which SQLAlchemy doesn't know how to interpret. Try creating a dictionary instead:parameters=[ "name", my_name, "class", my_class, "gender",...
25 Mar 2024 by Member 15783420
I have created a Tkinter desktop app with SQLalchemy as a database. When I insert a data in database the error below incurred: What I have tried: from sqlalchemy import text, create_engine engine = create_engine("sqlite:///my_db.db") my_conn...
25 Mar 2024 by Mircea Neacsu
Examines the performance of SQLite in multi-threading applications
28 Feb 2024 by Richard MacCutchan
Quote: It worked c.executemany instead of c.execute, you are right! Added to remove from Unanswered queue.
27 Feb 2024 by Member 15783420
I have using the SQLite3 to insert the multiple records with the placeholder, however I have encounter the above issues. However, when I run the code it was appear the error " InterfaceError: Error binding parameter 0 - probably unsupported...
14 Feb 2024 by CHill60
@_Asif_ 's solution will work with the data you provided although I would have used UNION instead of UNION ALL (the net effect is the same because there cannot be duplicates due to the tablename column). But it's worth pointing out that if there...
13 Feb 2024 by _Asif_
You can use the below approach to achieve your desired result. DECLARE @TabAnaOra1 TABLE ( Var1 decimal(6, 3), Var2 decimal(6, 3), Name varchar(20) ); DECLARE @TabAnaOra2 TABLE ( Var1 decimal(6, 3), Var2 decimal(6, 3),...
12 Feb 2024 by Graeme_Grant
SqLite does support Multithreading: Using SQLite In Multi-Threaded Applications[^] and here: Write-Ahead Logging[^]
12 Feb 2024 by GiulioRig
Hello friends, I wanted to ask a question about a SELECT statement in SQLite3. I have 4 tables structured as shown in the diagram, |-------------------------| | TabAnaOra1 | |-------------------------| | Var1 | Var2 | Name |...
12 Feb 2024 by GiulioRig
Hi guys i have version of sqlite 3.12 in linux mint last version i ask if anyone have experience about concurrence insert data in Sqlite i have 3 script and i want run not in serial but in parallel for reduce time of insert data , how...
14 Nov 2023 by Andre Oosthuizen
The above is not really a full on solution, sorry... To move data based on a specific condition, such as where your 'txYear' column equals a value from a TextBox as in '2021' your code should look like the following using 'ImportRow' with the...
13 Nov 2023 by Choroid
Is ImportRow the best way to move the data to the other table? I still do not know how to use "ImportRow" and per @Richard MacCutchan began to think about a simple app that selected the data from one table and inserted that data in another table....
11 Nov 2023 by Richard MacCutchan
It would be quicker to write a simple app that inserts the records into the new table, by SELECTing the relevant ones from the original. See SQLite INSERT[^].
11 Nov 2023 by Choroid
I create an app with one table using vb.net and entered some data. Then I decide I wanted another table so I created another table without delete the original table both tables have the same column names. I would like to use ImportRow to move...
13 Sep 2023 by Member 11314626
Not an expert in SQL yet. :) Let us assume we have the below table: Table A (id1 and id2 are primary keys) Columns: id1 id2 status 1 1 true // values entry 1 2 false 3 4 true 3 5 false Now...
30 Aug 2023 by Richard Deeming
Griff's answer works if you only have two entries for each id1. But there's nothing in your question to suggest such a limitation. :) A correlated sub-query with a Not Exists is probably the clearest solution: SELECT DISTINCT id1 FROM A As A1...
30 Aug 2023 by OriginalGriff
DISTINCT isn't what you want: you need a GROUP BY[^] clause. If you GROUP BY id1 with a WHERE selecting for true entries only, the COUNT method will return 1 for each id value - which means you aren't interested in it. So try this: SELECT id1...
12 Jul 2023 by brahim farhat (AAD)
My App crachs in some devices with error : ERROR : MM-DD HH:MM:SS 8379 8379 E libc : access denied finding property "re.vendor.pref_scale_resolution" I tried find to find what causes this error and i find it causes by SQLite database and...
12 Jul 2023 by brahim farhat (AAD)
Just changed checking method to this and the problem solved: private boolean checkDataBase() { File databasePath = context.getDatabasePath(DATABASE_NAME); return databasePath.exists(); }
22 Jun 2023 by Member 8840306
I am new in data base phpmyadmin Here my query that is giving error ALTER TABLE students ADD CONSTRAINT fk_enrollment_student FOREIGN KEY (student_id) REFERENCES enrollments (student_id); Here are structure of my table table 1 table 2 table...
22 Jun 2023 by k5054
I think you have your relationship between students and enrollments backwards. As written, you are trying to construct a dependency for the students table on enrollments. I.E. every student must have one and only one enrollment. This...
30 May 2023 by brahim farhat (AAD)
I want to back up and restore my SQLite database I read some online questions and answers but couldn't figure it out yet I read about BackupAgentHelper but I can't understand how it works i also tried FileInputStream but this not working all the...
29 May 2023 by brahim farhat (AAD)
I want to check within multiple strings for which one is null and then set a value "0.0" for the null one ? I am getting values from SQLite database is there any way to avoid using if else if else for every string? What I have tried: I tried...
29 May 2023 by OriginalGriff
Another solution is to provide the field(s) with default values: SQLite Default Constraint - Tutlane[^] If you do that, then a NULL insert will be replaced with the default by the DB engine.
29 May 2023 by Dave Kreskowiak
There's so much wrong here. First, if null values from the database are invalid, those values never should have been allowed to be null when written to the database. Next, you keep saying "string" and the value should be "0.0". Well, that's a...
24 May 2023 by brahim farhat (AAD)
I am trying to sum profits with avarage price of both purchase price and sale price this is the result that i expect according to calculator: 24*(24*4)/24-24*(36*2.333+24*2.5+48*2.4)/108 The result is: 38.4026667 How to get this result in...
23 May 2023 by Graeme_Grant
Here is how I would look at it before I create the Sql statement: item 1. 36 2.333 83.988 item 1. 24 2.57 60 item 1. 48 2.4 115.2 Total 108 259.188 avg purchase price = 259.188 / 108 = 2.399888889 So if sell price is 4.00 * 24 = 96 The...
23 May 2023 by brahim farhat (AAD)
I solved my problem by this query : SELECT sa_id, sa_date, p_name, cu_name, sa_quantity, sa_price, sa_amount, Sum(pur_quantity * pur_price) / Sum(pur_quantity) AS...
21 May 2023 by brahim farhat (AAD)
I have 4 tables in my database SQLITE as following: 1- products 2- customers 3- sales 4- purchases sales table has product ID (pro_id) and customer ID (cu_id) I am trying to join customers and products in sales using inner join but my problem...
21 May 2023 by Wendelius
The relations between tables are not quite clear but are you looking for a correlated subquery? Something like SELECT sa_id, sa_date, p_name, cu_name, sa_quantity, sa_price, sa_amount, ...
11 May 2023 by Stan Huang
See below code snippet, I wonder what the colons (':') in the SQLite statements mean. I studied at SQLite tutorials but can't figure it out. The colons are among sqlite3_prepare_v2 , sqlite3_bind_int64 and sqlite3_prepare_v2 statements of...
9 May 2023 by CPallini
It is used to bind a variable, see for instance: https://stackoverflow.com/questions/2177978/what-does-the-colon-sign-do-in-a-sql-query[^].
4 May 2023 by brahim farhat (AAD)
I am getting wrong result from SQLite database when using avg() function! In my database SQLITE table_name i have the following data: Item_ID Item_name quantity price 1. Item1 24 2.333 1. Item2. 36 2.083 1. ...
4 May 2023 by Richard Deeming
The result is correct, and is precisely what you asked for. The sum of the price column is 11.248; dividing that by the number of rows (5) gives 2.2496, which is the result you are getting. The only way to get your expected value is to take the...
3 Apr 2023 by Choroid
Please excuse my analogy of birth certificates I used it for any novice like myself that might read this question. I have two projects a VB.Net project DBCall and a Class Library Project DBControl. When I create the DB Table the primary key is an...
3 Apr 2023 by Choroid
The issue from my point of view as a novice learning C# and how to use the Class Library is most code I looked at the design was to get data from the Class Library most times I did not find code passing data into the Class Library. I found one...
31 Mar 2023 by Member 4206974
A PHP class that uses PDO for creating a table from JSON Objects
18 Mar 2023 by OriginalGriff
First off, don't use static for your ID - that means there is only one per application and that's not necessarily the case when you create instances of the form as your code does. Secondly, Never concatenate strings to build a SQL command. It...
7 Feb 2023 by faizy001
Hi i am working a LocalDb Application in Xamarin Form. My Requirement is to save Data Locally using SQLite DB. i have created successfully Save interface and method. Data is coming from the xamarin forms successfully but only one data is storing...
7 Feb 2023 by Richard MacCutchan
According to the code you have posted, obj is not a list but a simple object. If you mean that you want to save each member of the object into a separate field of the database, then you need to redesign your table to accomodate all the different...
3 Feb 2023 by JBartlau
This article demonstrates how Report Server offers a distribution of reports that save time, increase efficiency, and reduce potential errors.
2 Feb 2023 by iampradeepsharma
Hi all , I have an application written in MFC which uses MS Access as the database. Now, I want to migrate this database to SQLite. I have few questions around it : 1. Should I write a framework which creates all the equivalent classes such as...
2 Feb 2023 by OriginalGriff
To be honest it sound like your original app is badly designed, if the actual database is that tightly coupled to your business and / or presentation code - in a well designed app, it should be possible to extract the DB related code and replace...
21 Jan 2023 by Choroid
OK this code was rewritten from a VB.Net application I am now trying to adapt it to C# First and most confusing NO Exception is thrown I am using VB Helper and can see the table and columns I will include the code that creates the table which...
20 Jan 2023 by OriginalGriff
Graeme_Grant's suggestion of the finally block is good, but unnecessary - since you have a using block around each element, the object created in it is Disposed when you leave the block by any means, which means it is automatically Closed as...
20 Jan 2023 by Member 12692000
I'm trying to add data to a table in a SQLite database by getting data from a excel file using the fastexcel library. But I cannot figure out how do I get values from specific cells/column of a row in a worksheet. Can anyone help me with this...
20 Jan 2023 by CHill60
From the examples they have given in that project, Read example 2 has this snippet var rows = worksheet.Rows.ToArray(); //Do something with rows Console.WriteLine(string.Format("Worksheet Rows:{0}", rows.Count())); It...
18 Jan 2023 by Choroid
I have been fiddling with this code for 4 hours I am trying to create a SQLite Database I will Post the article I have been following and my code What I have tried: Using SQLite in C#/VB.Net[^] namespace Contacts { public partial class...
18 Jan 2023 by Choroid
This code structure is not great but it does create the Database Any suggestions on how to change the code structure would be most welcomed I did learn how to capture the Exception which aided in the rewrite of the code namespace Contacts { ...
18 Jan 2023 by Graeme_Grant
I have written, IMHO, a better implementation for Working with SQLite in C# & VB[^] that does a lot more. It's been used in a number of commercial apps. With the library from my article, the DbContext has an Exists method for checking if the DB...
16 Jan 2023 by Member 12692000
When I perform edit on an existing record(SQLite database), just before saving the edit I want to store the previous values of all columns of the said database row using c# in my WPF window app and store it in a txt/log file. To do this I'm...
16 Jan 2023 by Richard Deeming
before.Except(after) will depend on the Bills class correctly implementing the IEquatable interface, or at the very least providing correct overloads of GetHashCode and Equals(object). before.Intersect(after, new BillsComparer()) will...
15 Jan 2023 by Dave Kreskowiak
There's various ways of doing this. Google for "sqlite database change history[^]" for techniques and discussions.
15 Dec 2022 by Patrick Skelton
I have a WPF project that uses SQLite. My current version builds and runs fine. I have just restored the last-deployed version from Git. The code builds but the following post-build commands on the main exe project fail: xcopy...
15 Dec 2022 by adriancs
Set your project build platform to "Any CPU", then install the nuget package "System.Data.SQlite".
10 Dec 2022 by zmzk_1
I work on project c# with SQL server and I changed the database in SQLite I faced a problem with between date filter in the crystal report I try this code it shows the last item date only and sometimes not showing anything any help What I have...
10 Dec 2022 by OriginalGriff
Pass the dates as a parameterised query: that way the value received by the DB engine will already be a DATE based value and the comparison should work fine: Parameters - Microsoft.Data.Sqlite | Microsoft Learn[^] That assumes of course that...
6 Dec 2022 by Chris Aug2022
Trying to get an SQL select/join query so that I get the musicians first/last name with the instruments they play with a many-to-many relationship. Also trying to get the musicinas that play piano(two separate queries) The tables are as...
6 Dec 2022 by OriginalGriff
Look at your tables: The musicians hold the people names. The instruments hold the instruments they might play The musician_instruments links the two together. So if you want to ask "tell me all the musicians who play the piano" you need to...
13 Oct 2022 by meister meister
I have a function that the user can add a budget. In the python shell, when I am adding a budget there is no error. But when I am going for the route where I am adding my budget, it gets an error. This is the error I get: ...
10 Oct 2022 by Prahlad Yeri
After a little experimenting, I found the solution to this myself. As strange as it may sound but it looks like `adapter.Update()` requires a dataset along with the actual table name in order for this to work. I was passing the table object...
10 Oct 2022 by Prahlad Yeri
My situation involves batch updates to individual tables in an Sqlite database through ADO.NET objects. I use the `DataAdapter.Update()` method to push the changes which works well: DataTable changes = dataset.Tables[table].GetChanges(); ...
13 Sep 2022 by Hardi Mahendra
Where is the condition. In table_a, if col_a and col_b = col_p then col_a + col_b and the result is adding to col_q in table_b and col_p in table_a to col_p table_b. try{ String sql0 ="SELECT col_p FROM table_a"; PreparedStatement pst0 =...
12 Sep 2022 by Member 12885549
I had sql query: IF EXISTS(SELECT 1 FROM Amount WHERE ID = 1 AND ClientId IS NULL) BEGIN UPDATE Amount SET Price = 11 WHERE ID = 1 AND ClientId IS NULL PRINT 'Updated' END ELSE BEGIN INSERT INTO Amount (ID,...
12 Sep 2022 by CHill60
SQLite allows for "UPSERT" - which is what you are trying to do. See SQLite Query Language: upsert[^] You will need to ensure that you are enforcing uniqueness - e.g. on the ID
12 Sep 2022 by Richard MacCutchan
See Query Language Understood by SQLite[^]
12 Sep 2022 by Dave Kreskowiak
From the MySQL documentation[^] for IF says you cannot use an IF outside of a FUNCTION.
10 Sep 2022 by YunusShuaib
import sqlite3 import os import csv if os.path.isfile('phones.db'): os.remove ('phones.db') conn= sqlite3.connect('phones.db') db=conn.cursor() db.execute("PRAGMA foreign_keys = ON") db.execute ("""CREATE TABLE phones ...
10 Sep 2022 by OriginalGriff
When you asked the same question an hour ago: How do I get my code to work[^] I told you what you need to do. Reposting the same thing doesn't change the answer: go back and read it again.
10 Sep 2022 by YunusShuaib
import csv import sqlite3 import os if os.path.isfile('phones.db'): os.remove ('phones.db') conn= sqlite3.connect('phones.db') db=conn.cursor() db.execute("PRAGMA foreign_keys = ON") db.execute ("""CREATE TABLE phones ...
10 Sep 2022 by OriginalGriff
As I said yesterday, you need to look at error messages, and at your code: IntegrityError: datatype mismatch phones.py, line 37 Lines 36 and 37: to_db = [row[0], row[1], row[2], row[3], row[4], row[5] ] db.execute('''INSERT INTO customer...
9 Sep 2022 by YunusShuaib
import sqlite3 import os import csv # Remove database if exist if os.path.isfile('car.db'): os.remove('car.db') #Create database and open database conn=sqlite3.connect('car.db') db=conn.cursor() db.execute("PRAGMA foreign_keys = ON") ...
9 Sep 2022 by OriginalGriff
"Index out of range" means that you are trying to access an array element that doesn't exist. In Python, arrays indexes start as zero, and run to N - 1 where N is the number of elements in the array. So an array with three elements will have...
1 Sep 2022 by Richard MacCutchan
Your self.tenlistchecks contains a single element which is the array of tuples (double brackets): [[(120, '21-08-2022', '1112', 'Alfa Romeo', 'james'), (122, '21-08-2022', '465', 'Buick', 'daniel '), (123, '21-08-2022', '789', 'Buick', 'daniel...
31 Aug 2022 by asaad kittaneh
I am trying to select rows and fetch them from the DB table and then insert them into a list so I can insert all of the rows at once into the database. but I got an error : self.dashboard_buying_checks_dates = self.cursorObj.executemany(...
23 Aug 2022 by YunusShuaib
import sqlite3 loop = True def purchase_info(): conn = sqlite3.connect('car.db') cursor = conn.cursor() sql = '''SELECT clients.First_name, clients.Surname, cars.Make, cars.Model, purchase.Date_of_Purchase FROM ((purchase INNER JOIN...
23 Aug 2022 by OriginalGriff
Start here: SQL Joins[^] Then think about your data design, and exactly what you want to retrieve with the JOIN. You'll work it out!
23 Aug 2022 by YunusShuaib
import sqlite3 import os import csv # Remove database if exist if os.path.isfile('car.db'): os.remove('car.db') #Create database and open database conn=sqlite3.connect('car.db') db=conn.cursor() db.execute("PRAGMA foreign_keys = ON") ...
23 Aug 2022 by Richard MacCutchan
db.execute("""CREATE TABLE purchase PurchaseID INTEGER PRIMARY KEY autoincrement, You need an open parenthesis before PurchaseID thus: db.execute("""CREATE TABLE purchase (PurchaseID INTEGER PRIMARY KEY autoincrement,
22 Aug 2022 by Member 15744868
Using flask SQLAlchemy and SQLite I have a database for a game. In this game I need to combine 2 elements to make a third. the first element comes from the column Main and the second is the name of a column where, in that row of main, the final...
22 Aug 2022 by OriginalGriff
Assuming that main, fire, water, air, and earth are your column names, it's simple: SELECT water AS Combination FROM MyTable WHERE Main = 'fire'
12 Aug 2022 by just_123
I did it with this Python code (link attached)
12 Aug 2022 by basurajkumbhar
Hi all of you,I have created one application in vb.net and i am used mdb database.It works fine there is no any problem in that application.I want to convert all mdb table or data in that database to Sqlite.In my database there are 3 lakh above record it take some time to load data...
15 Jul 2022 by prasad patil Jul2022
Hi I have orderid and orderdate column. orderdate containing date format like 'yyyy-mm-dd'. i want to display the order placed in the month of February. How can we achieve this in the SQL? Waiting for quick response. What I have tried: I...
15 Jul 2022 by prasad patil Jul2022
Thank U all for your response. Below is the solution for the problem. SELECT * from orders where (DATEPART(mm, orderdate)) = 2
14 Jul 2022 by OriginalGriff
SELECT ... WHERE DATEPART(m, MyDateColumn) = 2
13 Jul 2022 by Member 12401110
I have been getting the above error and I can't figure it out but this is the code I tried: What I have tried: string constring = "Data Source=AnyStore.db;Version=3;New=True;Compress=True;"; SQLiteConnection con = new...
13 Jul 2022 by OriginalGriff
Try opening the connection before you begin the transaction. SqlConnection.BeginTransaction Method (System.Data.SqlClient) | Microsoft Docs[^]
7 Jul 2022 by DEB4u
Hi,I've developed a windows application which runs on a sqlite database. I'm packaging that .db file with installer. But i want that this .db file should not be opened by any sqlite editor like SqliteAdmin etc.. ANy idea how to do this??Thank you
7 Jul 2022 by Michael Haephrati
To password protect and to encrypt an sqlite database, using military grade encryption, you will need to buy SQLite Encryption Extension[^]