createrepo_c library 1.2.1 C library for metadata manipulation

Data Structures | Macros | Typedefs | Enumerations | Functions
SQLite metadata API.

Module for writing sqlite metadata databases. More...

## Data Structures
union | cr_Statements
struct | cr_SqliteDb

## Macros
#define | CR_DB_CACHE_DBVERSION 10
#define | cr_db_open_primary(PATH, ERR) cr_db_open(PATH, CR_DB_PRIMARY, ERR)
#define | cr_db_open_filelists(PATH, ERR) cr_db_open(PATH, CR_DB_FILELISTS, ERR)
#define | cr_db_open_other(PATH, ERR) cr_db_open(PATH, CR_DB_OTHER, ERR)

## Typedefs
typedef struct _DbPrimaryStatements * | cr_DbPrimaryStatements
typedef struct _DbFilelistsStatements * | cr_DbFilelistsStatements
typedef struct _DbOtherStatements * | cr_DbOtherStatements

## Enumerations
enum | cr_DatabaseType { CR_DB_PRIMARY, CR_DB_FILELISTS, CR_DB_FILELISTS_EXT, CR_DB_OTHER, CR_DB_SENTINEL }

## Functions
cr_SqliteDb * | cr_db_open (const char *path, cr_DatabaseType db_type, GError **err)
int | cr_db_add_pkg (cr_SqliteDb *sqlitedb, cr_Package *pkg, GError **err)
int | cr_db_dbinfo_update (cr_SqliteDb *sqlitedb, const char *checksum, GError **err)
int | cr_db_close (cr_SqliteDb *sqlitedb, GError **err)

## Detailed Description

Module for writing sqlite metadata databases.

Example:

cr_Package *pkg;
cr_SqliteDb *primary_db;
// Load pkg (See parsepkg or parsehdr module)
// Create primary sqlite database
primary_db = cr_db_open_primary("/foo/bar/repodata/primary.sqlite", NULL);
// Add all packages here
cr_db_add_pkg(primary_db, pkg, NULL);
// Add checksum of XML version of file (primary in this case)
cr_db_dbinfo_update(primary_db, "foochecksum", NULL);
// Cleanup
cr_db_close(primary_db, NULL);

## Macro Definition Documentation

## ◆ CR_DB_CACHE_DBVERSION

#define CR_DB_CACHE_DBVERSION 10

Version of DB api

Definition at line 59 of file sqlite.h.

## ◆ cr_db_open_filelists

#define cr_db_open_filelists | ( |  | PATH,
|  |  | ERR
| ) |  | cr_db_open(PATH, CR_DB_FILELISTS, ERR)

Macro over cr_db_open function. Open (create new) filelists sqlite sqlite db.

- creates db file
- creates filelists tables
- creates info table
- tweak some db params
  Parameters

    PATH | Path to the db file.
    ERR | **GError

  Returns
    Opened db or NULL on error

Definition at line 117 of file sqlite.h.

## ◆ cr_db_open_other

#define cr_db_open_other | ( |  | PATH,
|  |  | ERR
| ) |  | cr_db_open(PATH, CR_DB_OTHER, ERR)

Macro over cr_db_open function. Open (create new) other sqlite sqlite db.

- creates db file
- opens transaction
- creates other tables
- creates info table
- tweak some db params
  Parameters

    PATH | Path to the db file.
    ERR | **GError

  Returns
    Opened db or NULL on error

Definition at line 129 of file sqlite.h.

## ◆ cr_db_open_primary

#define cr_db_open_primary | ( |  | PATH,
|  |  | ERR
| ) |  | cr_db_open(PATH, CR_DB_PRIMARY, ERR)

Macro over cr_db_open function. Open (create new) primary sqlite sqlite db.

- creates db file
- creates primary tables
- creates info table
- tweak some db params
  Parameters

    PATH | Path to the db file.
    ERR | **GError

  Returns
    Opened db or NULL on error

Definition at line 106 of file sqlite.h.

## Typedef Documentation

## ◆ cr_DbFilelistsStatements

typedef struct _DbFilelistsStatements* cr_DbFilelistsStatements

Compiled filelists database statements

Definition at line 73 of file sqlite.h.

## ◆ cr_DbOtherStatements

typedef struct _DbOtherStatements* cr_DbOtherStatements

Compiled other database statements

Definition at line 75 of file sqlite.h.

## ◆ cr_DbPrimaryStatements

typedef struct _DbPrimaryStatements* cr_DbPrimaryStatements

Compiled primary database statements

Definition at line 71 of file sqlite.h.

## Enumeration Type Documentation

## ◆ cr_DatabaseType

enum cr_DatabaseType

Database type.

Enumerator
CR_DB_PRIMARY | primary
CR_DB_FILELISTS | filelists
CR_DB_FILELISTS_EXT | filelists-ext
CR_DB_OTHER | other
CR_DB_SENTINEL | sentinel of the list

Definition at line 63 of file sqlite.h.

## Function Documentation

## ◆ cr_db_add_pkg()

int cr_db_add_pkg | ( | cr_SqliteDb * | sqlitedb,
|  | cr_Package * | pkg,
|  | GError ** | err
| ) |  |

Add package into the database.

Parameters

  sqlitedb | open db connection
  pkg | package object
  err | **GError

Returns
  cr_Error code

## ◆ cr_db_close()

int cr_db_close | ( | cr_SqliteDb * | sqlitedb,
|  | GError ** | err
| ) |  |

Close db.

- creates indexes on tables
- commits transaction
- closes db
  Parameters

    sqlitedb | open db connection
    err | **GError

  Returns
    cr_Error code

## ◆ cr_db_dbinfo_update()

int cr_db_dbinfo_update | ( | cr_SqliteDb * | sqlitedb,
|  | const char * | checksum,
|  | GError ** | err
| ) |  |

Insert record into the updateinfo table

Parameters

  sqlitedb | open db connection
  checksum | compressed xml file checksum
  err | **GError

Returns
  cr_Error code

## ◆ cr_db_open()

cr_SqliteDb* cr_db_open | ( | const char * | path,
|  | cr_DatabaseType | db_type,
|  | GError ** | err
| ) |  |

Open (create new) other sqlite sqlite db.

- creates db file
- opens transaction
- creates other tables
- creates info table
- tweak some db params
  Parameters

    path | Path to the db file.
    db_type | Type of database (primary, filelists, other)
    err | **GError

  Returns
    Opened db or NULL on error

cr_db_dbinfo_update
int cr_db_dbinfo_update(cr_SqliteDb *sqlitedb, const char *checksum, GError **err)
cr_db_close
int cr_db_close(cr_SqliteDb *sqlitedb, GError **err)
cr_db_open_primary
#define cr_db_open_primary(PATH, ERR)
Definition: sqlite.h:106
cr_db_add_pkg
int cr_db_add_pkg(cr_SqliteDb *sqlitedb, cr_Package *pkg, GError **err)
cr_SqliteDb
Definition: sqlite.h:88
cr_Package
Definition: package.h:84