Questions tagged [sqlite]

15745 questions
1

votes
2

answer
3.3k

Views

SQLite Union of n tables with m columns

I have this problem. There are n tables created dynamically and each table has m columns, the columns could be repeated. This tables have in common 2 columns but there is no related data between them, for example: Table1 | A | B | Col1 | Col2 | Table2 | A | B | Col3 | Col4 | Table3 | A | B | Col1 |...
cbedoya
1

votes
1

answer
139

Views

Find SQLite Column Names in Empty Table/View in an attached database

The same thing as Find SQLite Column Names in Empty Table with the exception that I have a view that is part of an attached database. Because the database is attached the PRAGMA table_info( your_table_name ); solution doesnt work. Furthermore, trying to parse the query string is also ridiculous beca...
chacham15
1

votes
1

answer
431

Views

SQLite and Ruby rescue

I'm following the pretty great SLite & Ruby tutorial over at ZetCode and have run into a silly question. What exactly is going on here? rescue SQLite3::Exception => e puts "Exception occured" puts e I conceptually get what's happening: if an exception is raised, it gets printed on the screen. But w...
loganhasson
1

votes
3

answer
19.1k

Views

how to access database sqlite in android

Due to your solutions I have finished my application, I came here for last question about my current application, the database I created I am not able to access it, I read that is within the system of android so what should I do to access the database and export it ? public class DBAdapter { priv...
Utman Alami
0

votes
1

answer
7

Views

Django admin panel renders “s” after table/model names

I have no idea what's going on, here's a screenshot
Jojo
1

votes
2

answer
1.3k

Views

Python: Proper way to store list of strings in sqlite3 or mysql

I'm trying to store a list of string values into a sql database. list = ['please','help','me'] I've tried converting to unicode and using the array.array('u',list) unicode_list = unicode(list) array.array('u', list) This is not producing the results that I want. I'm not too concerned with being abl...
django-d
1

votes
3

answer
329

Views

List view does not update at all

Hi i am using view pager indicator with three fragments and in one of the i have a list view that show the content of my SQLite Database but when a add data to my table the list view doesn't show he new data that i have added here is my code: public class caleryhistory extends SherlockListFragment {...
Like
1

votes
1

answer
7.1k

Views

how to import data from xml file to sqlite database

I have two xml files for android project first consist approx 550 records of districts in India and second file consists of approx 40 records of states of India Now i want to import it in a sqlite database which consist two fields first district and second state and each record from xml should inser...
Surya
1

votes
2

answer
306

Views

Storing and Displaying String from SQLite to MainActivity

I am new to android, just days old to SQLite Database. In my application, I need to store 10 Strings in database, that I can display on the Main Activity, one string at a time and the string will change on the swipe. I am following AndroidHive, but its not working for me. I can do the swipe part...
bhanu kaushik
1

votes
2

answer
944

Views

android sqlite orderby datetime always fetches 1st row

I am storing date and time in column of type DATETIME. After that I am trying to retrieve the earliest time. I am using this query String query_to_fetch_earliest="select * from "+TABLE_NAME+" order by datetime("+KEY_DATETIME+") DESC LIMIT 1"; SQLiteDatabase db = this.getWritableDatabase(); Cursor...
0

votes
3

answer
39

Views

Java how to Convert String Date format

How to Convert String date format example I have Date like this 2019-01-01 and change the format into 2019-01 the year and date only?
Dummy Dummy
1

votes
2

answer
967

Views

SQLITE : Check if column exists without trigger an error in php

My situation is this: I have an array that contains the names of the columns of a table I must, with a loop , iterates through the array and check if that field (this column name) exists in the table If it exists, I do not do anything, otherwise I have to add $array_column = ["column1 NOT NULL","co...
WhiteLine
1

votes
1

answer
85

Views

android: force close when try sqlite database on service

i want to getRawCount from sqlite database in service, but i getting error. Here's my code on service class : public int onStartCommand(Intent intent, int flags, int startId) { database_center helper = null; Cursor cursor; SQLiteDatabase db = helper.getReadableDatabase(); cursor = db.rawQuery("sele...
virho
1

votes
1

answer
790

Views

No such table - error inserting values in SQLite Android [duplicate]

This question already has an answer here: When is SQLiteOpenHelper onCreate() / onUpgrade() run? 14 answers I want to develop an application in which i need to use SQLite database in Android. Below is the code shown which is implementing the database and all its operations my application requires w...
POOJA GUPTA
1

votes
1

answer
78

Views

SQLite: complex update statment with inner join

Ok, I tried almost every solution on this forum and cannot make it work. I always get syntax error. Instead of loading the data and doing the dirty work manually, I am trying to see if I can do it by running only an SQL update query. I have 2 tables, one contains characters and another contains acti...
larienna
1

votes
1

answer
1.5k

Views

PDO SQLite cannot update record: “database is locked”

I'm struggling with this all day. I've read numerous posts, tried all suggestions but nothing works. This is my PHP code: try { $db = new PDO('sqlite:test.db'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $result = $db->query('SELECT * FROM v_test'); foreach ($result as $row) { ech...
Paul Meems
1

votes
2

answer
31

Views

How to go directly into a row in sqlite

I have a huge sqlite database with 800,000 rows and it takes a long time if the row is near the end like select * from tbl where id=578511. This is because the query runs from the beginning of the database, but is it possible to go just directly to that row as the id equals the rowcount.
krishna
0

votes
0

answer
9

Views

dplyr & gracefully dealing with SQL NULL values

I'm trying to use dplyr to work with SQL databases using R and I'd like to gracefully handle SQL's NULL values--either by simply filtering them out or treating them as zeros when the come up, depending on the scenario--without making any changes to the underlying database itself. (In other words, I'...
Steve S
1

votes
2

answer
4.7k

Views

Android: How to search data using SugarORM

I am not familiar with Sqlite and therefore is using SugarORM, a database library, with its documentation at http://satyan.github.io/sugar/creation.html Most of its function is same as that in sqlite, but using simplier commands. ExerciseDB public class ExerciseDB extends SugarRecord { @Column(name...
pearmak
1

votes
1

answer
2.5k

Views

Joining tables with different column name but same value in sqlite

I'm using SQLite to work with my database I have two different tables, with key columns that have different names but the same value. As such: shoes Identification | Name | Shoe size 1 Bob 10 2 John 12 payment PaymentID | Price | Year 1 20 201...
Flowdorio
1

votes
1

answer
52

Views

Autoincrement sub-item in relational table

I have a two tables (perfectly willing to change these tables as I'm in the planning phase): create table building ( buildingId integer primary key autoincrement, buildingName text ); create table rooms ( roomId integer primary key autoincrement, buildingId integer, FOREIGN KEY(buildingId) REFERENCE...
Deftness
1

votes
3

answer
771

Views

Why can SQLite not add up DECIMAL values?

sqlite> create table test (Qty DECIMAL(10,2)); sqlite> insert into test values(1059.79); sqlite> insert into test values(-1050); sqlite> insert into test values(83.58); sqlite> insert into test values(130.51); sqlite> insert into test values(-5); sqlite> insert into test values(-136.68); sqlite> ins...
Nikki Locke
1

votes
1

answer
2.9k

Views

SQLite INNER JOIN in python: sqlite3.OperationalError: no such column:

I'm having an issue with SQLite in python. The following code doesn't appear to work due to the error sqlite3.OperationalError: no such column: Company I'm trying to gather data from both of the tables and display them back to the user using tabulate but cannot proceed and I cannot figure out how t...
B. Anderson
1

votes
2

answer
610

Views

Android SQLite query returning multiple same columns

This query below in Android Sqlite is returning multiple of the same columns. For example, it is returning "meet_id" (3) times. The first (2) "meet_id" are correct with the right number while the third one is empty. The same happens for my "athlete_id" and "event_id". I am assuming this is because o...
Bob TheBuilder
1

votes
3

answer
3.8k

Views

sqlite3 can't import .csv file

I'm very new to DQL and sqlite. I've created a very basic database and am trying to import data from a .csv file. I watched a tutorial and have entered the following code: .import countries.csv countries This gives the following error: Error: cannot open "countries.csv" I'm sure im over looking some...
Charles
1

votes
2

answer
1.3k

Views

iOS sqlcipher fmdb “File is encrypted or is not a database”

This tutorial works just fine with the following pieces of code. pod 'FMDB/SQLCipher' ... - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainM...
zeeawan
1

votes
2

answer
3.8k

Views

ASP.NET MVC application reading data from SQLite database

Novice question: I have an SQLite db with some randomg movie info that I'm reading data from and adding said data to a view. However, right now it's going through the table and only adding the last record to the view. How do I add each record as the SQLiteDataReader is through the table instead of...
Left4Cookies
1

votes
2

answer
426

Views

Convert SQLite 3 database to CSV

I am looking for a way to convert my databases into CSV files. I use SQLite 3 through the terminal as well as from SQLiteStudio. I have not come across a simple way to export or save as a CSV, which makes me think I may not be able to do it in one step.
Ceej
0

votes
1

answer
15

Views

Index out of Bound While Reading Data from Database

As You will see in code I am getting database data into ArrayList and passing it into listview , Getting Exception at dataIntArrayList3.get(i). Actually there are two database, I am passing data of one database into listview adapter at time of fetching and getting databse of another database by usin...
earthling
1

votes
3

answer
5.5k

Views

inserting arraylist<String> values to sqlite in android

I have names and id's from listview in 2 different arraylist and would like to store id's and names from arraylist to string and then save them on a button click to sqlite. The problem with below code is that when 2 items are checked and button is clicked the items are inserting twice. And when the...
murtaza ali
1

votes
1

answer
309

Views

Script for Deleting old data from sqlite3 databases

Currently I'm deleting manually old data (old more than 90 days) from sqlite databases, so below are the steps currently following for that. so guys Is that possible to do this job using Bash Script ?? 1. cd /opt/db (my database location) 2. ls -lSh | head -n30 (sorting fr...
lfreez
1

votes
1

answer
278

Views

How can I write SQL statements for psycopg2 for PostreSQL and sqlite3?

I use the psycopg2 library for PostgreSQL in python for my production environment but I want to test my code with the sqlite3 library. The problem is that psycopg2 uses %s as a placeholder for parameter substitution, whereas sqlite3 uses ?. I am not happy with the code I got now, it looks like this:...
Jelle Besseling
1

votes
2

answer
693

Views

How to get the size of database in KB/MB

I am developing an Android application in Ionic where I put a pre-populated database in apk. User can insert and delete records and initially the size of DB file is 217kb . I want to track after some time what is the current DB file size on user's device. Thanks in Advance!
sam
1

votes
1

answer
987

Views

Knex where doesn't allow passing single string to `.where()`

I have the following line in a program written in Node.js using Knex and SQLite: await db.table("books") .innerJoin("items", "items.id", "books.item_id") .with("idx", db.raw(`instr(items.name, ?) asc`, name)) .where("idx > 0") .orderBy("idx") .select() Where db is a variable created by calling knex(...
1

votes
1

answer
26

Views

RecyclerView Adapter Async Manipulation

I have a RecyclerView that shows some data on the screen, Pretty simple. Now I need to theme the shown data view. the way I do this is by saving a key, value to SQLite adapter, I don't want to use SharedPrefs, This takes a long process to read over 120+ keys! and lags the UI a lot so I thought lets...
SamzSakerz
0

votes
0

answer
5

Views

Using SQL where condition more than once dynamically in Python

I created SQLite table called 'annotations' in python 3 where 'attribute' and 'feature' are 2 columns out of 10 columns. I want to select all rows when the following conditions exist. def extract(gff_list, keyword, feature): # some other codes c.execute("SELECT * FROM annotations WHERE attribute L...
Saleh
-1

votes
1

answer
17

Views

Question about android programming using SQL lite

i`m still new to android programming, i usually code using Android Studio, here is my question about SQL lite how do you accsess your database from your android phone? where do you put your .db file ? some says i need to put it inside the assests folder i often come through some tutorial where they...
InFocus
0

votes
1

answer
12

Views

How to RANK multiple columns of an entire table?

I have an SQLite table which is in the following format: student physics chemistry maths history english The student column has student name and the other columns have numeric values depicting score for the individual subjects. What I want to find out for each student is the rank of their subjects...
Tuhin
0

votes
0

answer
4

Views

get average value from sqlite database using nodejs and sqlite 3

I have the following code, where I am trying to insert a record into SQLite database and trying to read from it. let stmt = db.prepare('INSERT INTO ratings(post_id, rating) VALUES (?, ?)') stmt.run(1,4); stmt.finalize() // code above works succefully let stmt2 = db.prepare(`SELECT AVG(rating) as a...
Shobi
1

votes
2

answer
20

Views

If Query Didn't Find Any Match

I have a webpage that creates a cookie in client's computer named "token" with a random value inside when he is logging in. That cookie is created from a separate login page and not included here as the cookie is already getting created without problems. Then I match the cookie token's value from th...
haZh

View additional questions