sqlite

Concatenating a second string to a row already containing a string

I have a PHP process running as a result of a JavaScript AJAX request, which is potentially running for some time and will produce data from time to time. From a usability perspective, I'd like to be able to return data to the JavaScript as soon as it's produced, but this appears not to be possible. My workaround is to write it to an SQ...

Seeking Embedded Database alternative to SQLite. Must have foreign key contraint and transaction support?

Do you know of any SQLite alternatives (Portable/flatfile based/serverless) that have foreign key constraint and/or offer transaction support? ...

make zero appear last in a list of ascending numbers

I'm using SQLite in an Android application. In all of my tables I have a default row with an index of 0 that holds default values for that table. In most situations the default number for each field is 0 and that is the best number to use. However, when I sort my data using an ORDER BY statement I want to have all of my zero value fields...

sql combining two queries and truncating date

I am trying to truncate dates to only get year/month as opposed to the form they are in which is year/month/day.time What I want to do is count all of the cars that sold each month and all of the suvs that sold each month, having something like: // counts cars select SellDate, count(*) from category where machineIdentification =...

Common table expression functionality in SQLite

I need to apply two successive aggregate functions to a dataset (the sum of a series of averages), something that is easily and routinely done with common table expressions in SQL Server or another DBMS that supports CTEs. Unfortunately, I am currently stuck with SQLite which does not support CTEs. Is there an alternative or workaround...

How to merge N SQLite database files into one if db has the primary field?

I have a bunch of SQLite db files, and I need to merge them into one big db files. How can I do that? Added Based on this, I guess those three commands should merge two db into one. attach './abc2.db' as toMerge; insert into test select * from toMerge.test detach database toMerge The problem is the db has PRIMARY KEY field, and ...

Android -- SQLite + SharedPreferences, 2 Threads Simultaneous Read/Write?

Hello, I have two parts of a program (the actual app and a BroadcastReceiver) that could possibly try to connect to and modify a SQLite database and a SharedPreferences file. 1) I know you can make multiple connections to a single SQLite database. I also read that SQLite can "lock" the database when it attempts to modify or read from a...

Count on the same table

Hi, i have got a problem with my SQL Statement: Table structure: CREATE TABLE "tags" ( "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "page_id" INTEGER NOT NULL, "title" TEXT NOT NULL ); Now i want to select all the tags from one page and the frequency of this tag in the whole database. I have the following SQL statement: S...

Blackberry JDE and Sqlite timestamp

I am trying to store a date from a DateField into an sqlite database, but can't figure out what format to store/retrieve it in to preserve the value. I have been trying with the sqlite datatype as 'timestamp' and using 'long' in the application. When I retrieve the date though, it goes to 1970 instead of 2010-ish. Any recommendations?...

Monotouch data sync - why does my code sometimes cause sqlite errors?

Hi I have the following calls (actually a few more than this - it's the overall method that's in question here): ThreadPool.QueueUserWorkItem(Database.Instance.RefreshEventData); ThreadPool.QueueUserWorkItem(Database.Instance.RefreshLocationData); ThreadPool.QueueUserWorkItem(Database.Instance.RefreshActData); 1st point is - is it OK...

How to communicate with server's database from android phone?

Hello, I'm currently making an app where it would communicate with a simple database that will be hosted on a server. The database will only have three columns, a _id, title, and url link. I've successfully done this using the phone's local database using SQLiteDatabase but I want it so that any other phone can also access the same data...

When creating SQLite database for iPhone, how do I configure Z_METADATA and Z_PRIMARYKEY tables?

Hi, I'm trying to create a new SQLite database for the iPhone using SQLite Manager firefox add-on. From what I understand, Z_METADATA AND Z_PRIMARYKEY tables must be included. How do I configure these though? I've tried to replicate a database by adding the same columns in each of these tables (for Z_METADATA --> Z_VERSION, Z_UUID, Z_PLI...

Find and Replace in SQLite being mucked up by percent sign.

I'm trying to use this code: UPDATE media_items SET content_url = replace(content_url,’cd%20images’,'my%20music’); And I know that the percent signs are mucking it up, and I have to use some sort of escape to get them to read properly, but I've done a bunch of searching, and anything I find doesn't seem to work. What is the proper sy...

How to optimize delete with date range where clause?

I created an android app and there is a function that will periodically delete old records delete from tablea where col1 = 'value1' and col2 = 'value2' and postdate < '2010-06-14' It has performance problem when total number of row in tablea has more then 50,000. It take around 45 seconds to delete 500 records. I already have index f...

sqlite: how to find all rows in a table where ANY of the columns are null?

I have a very large CSV file that I imported into a sqlite table. There are over 50 columns and I'd like to find all rows where any of the columns are null. Is this even possible? I'm just trying to save myself the time of writing out all of the 50 different columns in a where clause. Thanks. ...

"SQLiteDatabase created and never closed" problem.

Hi, I have the same problem as in http://stackoverflow.com/questions/2280345/sqlite-database-leak-found-exception-in-android - I get "SQLiteDatabase created and never closed" although I close all my databases and cursors. But I am new to java, can someone please help me implement the solution in my context? since I am not using my own p...

android sqlite exception:java.lang.IllegalArgumentException: column '_id' does not exist

Hi all I created a sql lite database with the following columns: static final String dbName="demoDB"; static final String tableName="Employees"; static final String colID="EmployeeID"; then public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub db.execSQL("CREATE TABLE "+tableName+" ("+...

variable table name in sqlite

Question: Is it possible to use a variable as your table name w/o having to use string constructors to do so? Info: I'm working on a project right now that catalogs data from a star simulation of mine. To do so I'm loading all the data into a sqlite database. It's working pretty well, but I've decided to add a lot more flexibility, ...

High scores table

I am looking to add a (local, not online) high scores table to my Android app and I wanted to get some insight on the best way to approach the problem. I have a list of users (right now being saved out to a file and read back in as an array of User objects), and the high scores need to reference this data to populate the table with the ...

Closing DataMapper DB connection

Hello, my rails application generates lots of small sqlite databases using DataMapper. After data saved, .sqlite-file must be uploaded on a remote server and destroyed locally. My question is how to make DataMapper close .sqlite db connection and free repo's memory? Application should generate many databases, so it's important to save ...