Ecere SDK/eC Forums http://ecere.com/forums/ Print view |
|
EDA (Sqlite3) in console app http://ecere.com/forums/viewtopic.php?f=2&t=388 |
Page 1 of 1 |
Author: | samsam598 [ Mon Jul 07, 2014 11:25 pm ] |
Post subject: | EDA (Sqlite3) in console app |
Greetings! I tried to make use of EDA and make a simple program in console mode under windows,but I can't continue to the next step after this below.Simply put,I want to read and modify and write back some record from a sqlite3 database.How to make it under consoles?In the slider file under samples/db,I guess it makes use of some GUI controls which I don't want if in Console mode. Thanks. Code: Select all
|
Author: | jerome [ Tue Jul 08, 2014 9:14 am ] |
Post subject: | Re: EDA (Sqlite3) in console app |
Hi Sam, EDA does provide some controls which makes it easy to build a GUI to edit database fields. For example the ListSection / EditSection system which is used by the extras/genericEditor and in that MovieCollection sample, the generic FieldDataBox, and the more specific controls e.g. TableDropBox, DropDataBox, EditDropDataBox, FieldCheckButton, FieldDropDataBox, EditFieldDropDataBox. But you are in no way tied to use the GUI, the main EDA API is just database access. The core EDA classes are DataSource, Database, Table, Field and Row. You open a database from a data source, and you can open a table from a database. The Row class is used to add new rows, query existing contents or update contents. With the SQLite driver you can use SQL language with Row::Query(). You can also use the eC active records system to access the database in an object oriented manner. Usually when building an EDA app you will write your database schema using the dbtable keyword. (See movieSchema.ec) This will list all fields in each table, with their type, the name in the database, and the identifier to use when acessing them OO style. This will also automatically create these row classes specific to each table. e.g. defininig the dbtable "Movies" automatically create both a RowMovies class as well as a Movie identifier class. There are actually plans to make this more obvious by revising the dbtable keyword in favor of declaring it as a class ( http://ecere.com/mantis/view.php?id=515 ) I suggest you take a look at the accompanying slides for that sample at https://github.com/ecere/ecere-sdk/raw/ ... tation.odp if you haven't already. But here are some key points: Code: Select all
Code: Select all
If you're trying to open a SQLite table that was not created with EDA and a schema, you'd need to do something like: Code: Select all
Please let me know whether this helps and if you have any further questions Best regards, -Jerome |
Author: | jerome [ Tue Jul 08, 2014 9:23 am ] |
Post subject: | Re: EDA (Sqlite3) in console app |
I've filed this issue regarding opening tables not created by EDA: http://ecere.com/mantis/view.php?id=1086 |
Author: | samsam598 [ Sun Jul 13, 2014 8:51 pm ] |
Post subject: | Re: EDA (Sqlite3) in console app |
Below compiled but just crashed when running,sqlite3.dll and world.db3 are ready: Code: Select all
Code: Select all
|
Author: | jerome [ Sun Jul 13, 2014 9:21 pm ] |
Post subject: | Re: EDA (Sqlite3) in console app |
Hi Sam, Could you maybe send me that DB for me to take a look at it? When you use Query() with GetData() or the Row OO members this way, query results must always be "ROWID, *": Code: Select all
Do you have a field called Name in the table? Is fld null? As mentioned in my earlier post, if there is any 'references' or 'primary key' or anything other than basic field name / types using a table not created by EDA it won't work at the moment. Row row { tbl = tbl } set up a Row object to be used with that table. Cheers, -Jerome |
Author: | samsam598 [ Sun Jul 13, 2014 9:34 pm ] |
Post subject: | Re: EDA (Sqlite3) in console app |
Sorry I should have provided the db file to you for your closer look at. Here attached world.db3. Thanks again. |
Author: | jerome [ Thu Jul 17, 2014 6:12 am ] |
Post subject: | Re: EDA (Sqlite3) in console app |
Hi Sam, I took a look at world.db3 and you will run into issue http://ecere.com/mantis/view.php?id=1086 because of the NOT NULL and other stuff in the table schema. I also filed issue http://ecere.com/mantis/view.php?id=1088 to support a SQLite database with a different extension, that is the first problem you run into when your DB is named World.db3, it will not even try to open the right file. The work around for 1086 is to manually create the eda_table_fields table in the DB with the proper name and types. Work around for 1088 is to rename your file with a .sqlite extension. Again these issues only come up if this DB file will be coming from or be used with other non EDA-based software. Please let me know if these workarounds do not work for you and you would like to see this fixed urgently. Regards, -Jerome |
Author: | samsam598 [ Thu Jul 17, 2014 9:27 pm ] |
Post subject: | Re: EDA (Sqlite3) in console app |
Thanks Jerome. Here I tried to create eda_table,and made a copy of world.db3 and changed its extension to *.sqite(world.sqlite).it runs ,but no record printed in the consoole.It seems that just ran Code: Select all
Please help to figure me out where the problem is(I think there is something I did wrong when I tried to retrieve the records from the table,but I just don't know exactly what it is.): Code: Select all
|
Author: | jerome [ Mon Aug 18, 2014 9:24 pm ] |
Post subject: | Re: EDA (Sqlite3) in console app |
Hi Sam, Again, terribly sorry that I missed those posts. Gmail had been classifying those forums notifications has spam lately If it takes more than a couple days for me to answer any question again, please e-mail me directly . One thing I note in your sample there is that your Query call is not including the ROWID before the *, as mentioned in my earlier post: row.Query("select ROWID, * from city"); However, it should have printed something if there was any entry in the cities? How many rows were there in the DB? Is there more than one? If there is only one it's possible that the Query() was already at the first row and then Next() went past the last record... Please let me know if this is still an issue as you've asked this over a month ago, and if it is please attach your DB with the eda_table_fields table you created so that I can test the code. Regards, -Jerome |
All times are UTC-05:00 | Page 1 of 1 |
Powered by phpBB® Forum Software © phpBB Limited |