mardi 1 septembre 2015

How to compare Date in SQlite?

How to compare dates which stored as String in Sqlite Database and fetch data...?

I am storing date in a format DD.MM.YY

I have tried <= but it is working. And I want to compare only Date and not Time. So I am passing value as dd.mm.yy

I have tried "Select SUM(tramount) as s From mytrans where accno = " + acno + " AND trdate <= Datetime( '"+date+"' )" this too,but it is not working.

huge datareader to insert in sqlite ( XAMARIN IOS)?

I have a huge datareader from sql server to insert into a sqlite database. I'm using xamarin C#, my problem is that the datareader is very big and the foreach item in datareader is very slow.

I have 131 fields in this table and is not feasible to use the index, I mean that I know that if I use the index instead of the name of the field I got better speed, but this is not feasible because fields can change.

Is there a method to deal with the datareader as a whole and accelerate the inserts?

Is it a good idea to fill a database using a .txt?

I am currently learning how to use database in Android. For one of my app, I need to stock 500 string values in order to read them. Actually to fill my database, I read a .txt file at the database creation with all the string values inside. For each lines of .txt (corresponding to a string value), I create a new data in the database. The thing is I know that accessing a file can be long it is not a very good thing if there are thousands of values. According to that, I have two questions :

  • Is it really usefull to create a database ? (because I can directly access the string values by reading the .txt)

  • Is there a better way to fill the database ? Or a way to create a database already filled before the activity creation ? (because currently, each time you close the activity you close the database and each time you reopen it, it recreate and refill the database.)

how to connect 2 adobe air desktop application user

I created a one adobe air desktop application using html and javascript and one web application using phpmyadmin and cakephp. I used sqlite for the desktop application. I want to connect a 2 different abode air desktop application user to each other which are may be connected using the same building or may not be if any body knows then please let me know how to do this kind of stuff using adobe air

I want to save result to DB (like SQLite) when run testing with UiAutomatorTestCase in NO-rooted Android

I know how to save data into SQLite by SQLiteOpenHelper with one app. Is there any way to save data when i use UiAutomatorTestCase to write testing?

ps: I had tried that i can't push sqlite3 into /system/xbin in No-rooted android .

lundi 31 août 2015

How to insert into a junction table using a content provider/content values/AsyncQueryHandler

I'm trying to insert into a junction table in Android. I already set up a content provider and have been using an AsyncQueryHandler to perform a lot of my operations in classes that don't require loaders. However, I need to insert into a junction table, and I'm at a loss for how to handle querying the related tables in order to receive the _ID values to place into the junction tables via a content provider/queryhandler.

For example, from this post's answer: Automatically Create Insert Statements to Fill Junction Table in a Pre-Created DB

 insert into Name_Category values(
  (select _id from Categories where category='CAT1'),
  (select _id from Names where name='NAME1'));

(Edit) Here is an additional example: Insert into a junction table in SQLite

INSERT INTO ListsAndPlayers (ListsAndPlayersID, ListID, PlayerID)
VALUES (42,
    (SELECT ListID FROM Lists WHERE ListName = 'Los Angeles Dodgers'),
    (SELECT PlayerID FROM Players WHERE PlayerName = 'Clayton Kershaw'));

I have a very similar need in my application, and couldn't find any documentation on handling this with AsyncQueryHandlers or ContentProviders/ContentValues. What would the equivalent of this be using one of those?

Does anyone have suggestions for how they have handled this?

Thanks!

Unable to import a csv into a table in SQLite: no such table error

I have a wireshark dump in .csv format that I want to analyze. I tried importing the CSV file as described here. These are the commands I ran from the command line-

sqlite> create table network(no,time,source,dest,proto,info);
sqlite> .separator ",";
sqlite> .import E:\\Pavan\\_DataScience\\MP1\\network_data1\\challenge_network\\TestNetworkData.csv network;
Error: no such table: network;
sqlite> .tables
network
sqlite>

The .table command clearly shows that the network table is indeed present. I am not getting why the import command fails.

PS: I am running the sqlite3 executable downloaded from the official site on Windows.