Is there any way to convert ini codes to sqllite??
#1

Hello mates i really want help in this is there any ways to convert a ini script to sqllite ??
Reply
#2

Learn the SQL language, then look up some tutorials about SQLite on the forums.
Reply
#3

So there isnt any way to convert??
Reply
#4

Yes, you can convert any script to SQL.
Reply
#5

You can convert an INI file to a SQL row using a trick PAWN code.

Source:
pawn Код:
#pragma dynamic (20000)

#define MAX_STRING_SIZE (256)
#define MAX_INI_FIELDS (32)

stock SQL_Convert(const file[], DB:db, const table[])
{
    new File:h = fopen(file, io_read);
    if (! h)
        return printf("[initosql.inc] - ERROR: Cannot open file '%s'.", file);

    if (db == DB:0)
        return printf("[initosql.inc] - ERROR: Cannot open database file(.db) 'handle: %i'.", _:db);

    if (! table[0])
        return print("[initosql.inc] - ERROR: No table name entered.");

    new read[MAX_STRING_SIZE];
    new pos;

    new field[MAX_INI_FIELDS][32], value[MAX_INI_FIELDS][MAX_STRING_SIZE];
    new count;

    while (fread(h, read))
    {
        if (! read[0])
            continue;

        pos = strfind(read, "=");
        strmid(field[count], read, 0, ((read[pos - 1] == ' ') ? (pos - 1) : (pos)));
        strmid(value[count], read, ((read[pos + 1] == ' ') ? (pos + 1) : (pos)), strlen(read));

        count++;
    }
   
    new query[MAX_INI_FIELDS * MAX_STRING_SIZE + 256];
    format(query, sizeof (query), "INSERT INTO `%s` (", table);
    for (new i; i < count; i++)
    {
        if (i == (count - 1))
            format(query, sizeof (query), "%s`%s`) VALUES(", query, field[i]);
        else
            format(query, sizeof (query), "%s`%s`, ", query, field[i]);
    }
    for (new i; i < count; i++)
    {
        if (i == (count - 1))
            format(query, sizeof (query), "%s'%q')", query, value[i]);
        else
            format(query, sizeof (query), "%s'%q', ", query, value[i]);
    }
    db_query(db, query);

    fclose(h);

    return printf("[initosql.inc] - SUCCESS: INI file '%s' was successfilly contverted to SQLite row in table '%s'.", file, table);
}
Usage:
pawn Код:
main()
{
    new DB:db = db_open("Test.db");
    db_query(db, "CREATE TABLE IF NOT EXISTS `Users` (`Name` TEXT PRIMARY KEY, `Score` INTEGER)");
   
    /*
    test.ini has the following lines
    - Name = Gammix
    - Score = 69
    */

    SQL_Convert("test.ini", db, "users");

    db_close(db);
}
Reply
#6

Yeah thanks Gammix i knew this trick but it only converts ini files but is there any way to convert the script to sqllite
Reply
#7

Impossible
Reply
#8

You have to learn the SQL first...
Reply
#9

Learn SQL and use "find and replace" as good as possible. Other than that, I don't know of any way.
Reply
#10

ok is there any way to convert the mysql to sqllite?? (i learned sqllite now )
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)