DBFlow icon indicating copy to clipboard operation
DBFlow copied to clipboard

Execute a SQL statement

Open darkovski88 opened this issue 11 years ago • 4 comments

Hello, I dont know if this is really an issue, but Im interested if is it possible with DB flow to execute SQL statements? I have a exported database in a text file that I want to create a db from it in android?

Here is the example statements that I need to implement:

BEGIN TRANSACTION; CREATE TABLE android_metadata (locale TEXT); INSERT INTO android_metadata VALUES ('en_US'); CREATE TABLE Plan(bill_total REAL, calculationAmount REAL, consumer_id TEXT, contract_end TEXT, data_level_gb TEXT, data_level_id INTEGER, days_to_switch INTEGER, direct_from_operator INTEGER, flow TEXT, pid_ INTEGER, plan_id TEXT, network_generation_ TEXT, one_offs TEXT, partner_plan_id TEXT, payment_level TEXT, payment_level_id INTEGER, retailer_name TEXT, roaming_amount REAL, savings_amount REAL, savings_avg REAL, savings_percents INTEGER, operator_id INTEGER, PRIMARY KEY(pid_)); INSERT INTO Plan VALUES (0.0,0.0,'55f2bd632d69874748225814','Your contract ends in 91 days','1',2,91,0,'55f2bd565e06285a09750d90',0,'55f2bd653dc7412168a2afcb','3G',NULL,NULL,'No upfront',3,'Virgin',0.0,-276.0,30.0,-329,12);

darkovski88 avatar Sep 15 '15 15:09 darkovski88

You could use raw queries: https://github.com/Raizlabs/DBFlow/blob/master/usage/SQLQuery.md

I'd recommend you use the transaction manager and @Table extended from BaseModel thought.

Maybe the issue would be "The ability to import .db files" which is duplicated: https://github.com/Raizlabs/DBFlow/issues/386

arturonaredo avatar Sep 15 '15 23:09 arturonaredo

related to #415

darkovski88 avatar Oct 05 '15 09:10 darkovski88

@arturonaredo The SQLQuery link doesn't work.

Can you provide the correct link please?

shabeepk avatar Jul 07 '16 04:07 shabeepk

@arturonaredo your introduced link is not available

pishguy avatar Dec 10 '16 06:12 pishguy