dubuntu-team team mailing list archive
-
dubuntu-team team
-
Mailing list archive
-
Message #00128
Re: API and Database specification
Hey guys,
its been a while but it has given me a chance to work on my own project enough to get its first release out.
Anyway, just so i better understand it Jay, is that code SQL?
The naming is good it is easy to understand. When you get the basics done can you push it to the api branch, then i can pull it down and fiddle with my gui code until i can get something working between the db and gui, i may need your help on that since i have no experience with mysql or anything like that.
Ryan
> From: jay.27182818@xxxxxxxxx
> To: charl.wentzel@xxxxxxxxxxxxxx
> Date: Sat, 25 Jul 2009 15:51:26 +0300
> CC: dubuntu-team@xxxxxxxxxxxxxxxxxxx
> Subject: Re: [Dubuntu-team] API and Database specification
>
> hi,
> i was very busy with some urgent work and, sad to say, spent absolutely
> no time on coding. the database description will take a lot of space so
> i'll post it in another letter. in this one i'd like to describe the
> current state of the api:
>
> == s_db* db_open(void);
>
> opens a connection and populates 's_db' structure. currently it doesn't
> accept any arguments. it will accept connection related parameters and a
> language identifier that will be used for fetching localized data from
> the db.
>
> == bool db_close(s_db* db);
>
> closes a previously open connection and frees memory allocated for s_db
> instance. btw the 's_' prefix is part of my naming convention. it allows
> me to think less about possible namespace collisions as well as define
> variables/fields/etc with more natural names, e.g.:
>
> struct s_book{
> s_text text;
> };
>
> i don't insist on using it but in my code you can find it everywhere so
> i thought a little explanation would be necessary.
>
> == size_t db_exists(s_db* db, const char* path, bool* is_cat);
>
> checks whether a path exists in the database. the format for path is
> this:
>
> path = '/' | ( '/' name ){1,}
>
> examples:
> /
> /development/desktop
> /multimedia/audio/players/realplayer
>
> and this is how the function works: it creates a sha1 hash from the
> path, and fetches a record that matches the hash from a special table
> called 'rels' (short for relations). the matched record (if any)
> contains a package/category id and a boolean field 'is_cat' telling
> whether the record corresponds to a category or package. the parameter
> is_cat if not NULL accepts the value of this field and id is returned
> from the function.
>
> == s_db_item* db_read(s_db* db, const char* path);
>
> this function just fetches a record from either 'packs' or 'cats' table.
> it uses db_exists to obtain an id and populates a s_db_item structure
> with information from a corresponding record. s_db_item is used for both
> categories and packages. it contains several fields that are common for
> packages and categories and a union for those that differ. if this
> function succeeds it returns a pointer to a malloced s_db_item instance
> that can be destroyed with free.
>
> == bool db_write(s_db* db, const char* path, s_db_item* item);
>
> item is populated by the frontend. the function succeeds only when path
> is valid.
>
> == bool db_create(s_db* db, const char* path, s_db_item* item);
>
> adds a record to either 'cats' or 'packs'. s_db_item has a field 'type'
> that tells the function which table to use.
>
> == bool db_destroy(s_db* db, const char* path);
>
> removes a record from the db.
>
> == char** db_list(s_db* db, const char* path, bool** cats);
>
> lists all items inside a category. this function fails if path
> corresponds to a package. returns a list of null-term. strings. cats if
> not NULL contains an array of bools after the function returns.
>
> == bool db_set_language(s_db* db, const char* language);
>
> sets current language.
>
> == bool db_get_language(s_db* db, char* language);
>
> gets current language. language is a five character sequence:
>
> xx-XX
>
> e.g. en-US
>
> == that's it for the moment. i'm gonna add functions for
> adding/removing/listing repositories and functions for explicit
> pattern-matching.
>
> p.s.
> as we haven't come in terms on several quite important subjects yet i
> think now we should concentrate on working with packages and package
> categories and leave search categories/package groups/etc for future. if
> everyone will decide to go his own way then at least we will have some
> common codebase that can be used in both our approaches.
>
> jay
>
> On Thu, 2009-07-23 at 21:26 +0200, Charl Wentzel wrote:
> > Hi Jay
> >
> > How's your proposal coming? I'm quite anxious to see it.
> >
> > Regards
> > Charl
> >
> > PS: How did you project (and deadlines) go?
> >
> >
> > _______________________________________________
> > Mailing list: https://launchpad.net/~dubuntu-team
> > Post to : dubuntu-team@xxxxxxxxxxxxxxxxxxx
> > Unsubscribe : https://launchpad.net/~dubuntu-team
> > More help : https://help.launchpad.net/ListHelp
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dubuntu-team
> Post to : dubuntu-team@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dubuntu-team
> More help : https://help.launchpad.net/ListHelp
_________________________________________________________________
View photos of singles in your area Click Here
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fdating%2Eninemsn%2Ecom%2Eau%2Fsearch%2Fsearch%2Easpx%3Fexec%3Dgo%26tp%3Dq%26gc%3D2%26tr%3D1%26lage%3D18%26uage%3D55%26cl%3D14%26sl%3D0%26dist%3D50%26po%3D1%26do%3D2%26trackingid%3D1046138%26r2s%3D1&_t=773166090&_r=Hotmail_Endtext&_m=EXT
Follow ups
References