SA-MP Forums Archive
[Include] INI to SQLite converter - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] INI to SQLite converter (/showthread.php?tid=477025)



INI to SQLite converter - Emmet_ - 21.11.2013

INI to SQLite converter

Introduction
After having a discussion with [uL]Pottus here, I've decided to release this small but useful library which has the capability to convert INI files to a SQLite row.

How it works
There is only one function:

pawn Код:
Convert(file[], db[], table[], custom_field[] = "", custom_value[] = "", bool:create_columns = false);
Let's break that down:
How to use it
For example, if you've just converted your account system to SQLite and you want to convert a player's existing file upon connecting:

pawn Код:
public OnPlayerConnect(playerid)
{
    new
        path[32],
        playerName[24];

    GetPlayerName(playerid, playerName, sizeof(playerName));
    format(szPath, sizeof(szPath), "%s.ini", playerName);

    if (fexist(path))
    {
        Convert(path, "Accounts.db", "Accounts", "Username", playerName, true);
        fremove(path);
    }
    return 1;
}
That code will create all of the columns in the database by default (fetches them from the file) and add them into the database. Pretty simple, right?

Notes
I made this at around 2:00 AM last night and just finished it up today. Of course, I was tired last night so if there any bugs, you know what to do!

- This include will take up a significant amount of memory and CPU usage upon converting, so use it at your own risk!
- SQLite places a limit on how many columns you can add in one table creation, so use create_columns with caution!
- There might be bugs; if so, report them!

MySQL version
There is no MySQL version at the moment. However, creating one wouldn't be too hard. I don't have time to create one and test it right now, so you have to modify the code and do it yourself until I have enough time to create a MySQL version.

Download
Pastebin
Solidfiles


Re: INI to SQLite converter - HellYeah - 21.11.2013

This... is... FUCKIN' Awesome!
Thank you veryyyy much.


Re: INI to SQLite converter - knackworst - 21.11.2013

That's brilliant...


Re: INI to SQLite converter - ***Niko*** - 21.11.2013

epic,good work man


Re: INI to SQLite converter - PT - 21.11.2013

can i ask one thing?

you think SQLite is more better than MySQL?

@ Topic

nice work

+REP


Re: INI to SQLite converter - Emmet_ - 21.11.2013

Quote:
Originally Posted by PT
Посмотреть сообщение
can i ask one thing?

you think SQLite is more better than MySQL?

@ Topic

nice work

+REP
Yeah, for a reason why: click me.

Thanks y'all. If anyone can do some tests, I would be happy. :D


Re: INI to SQLite converter - ***Niko*** - 21.11.2013

Quote:
Originally Posted by Emmet_
Посмотреть сообщение
Yeah, for a reason why: click me.

Thanks y'all. If anyone can do some tests, I would be happy. :D
Well i need to do it from dini to INI then i will do it from INI to SQLite (ayayayyaya)
/laugs off


Re: INI to SQLite converter - Emmet_ - 21.11.2013

Quote:
Originally Posted by ***Niko***
Посмотреть сообщение
Well i need to do it from dini to INI then i will do it from INI to SQLite (ayayayyaya)
/laugs off
Cool, yo! If you plan on converting a bunch of files and removing them after, you should back them up first, JUST in case that something MIGHT go wrong.

Oh, and a fun fact: This works with every INI system (y_ini, dini, *name 50 others here lol*).


Re: INI to SQLite converter - PT - 21.11.2013

Quote:
Originally Posted by Emmet_
Посмотреть сообщение
Yeah, for a reason why: click me.

Thanks y'all. If anyone can do some tests, I would be happy. :D
hum ok

but that dont say why ( the reason ) SQLite is more better than MySQL


with SQLite is possible do one UCP (in on website, you understand?)?


Re: INI to SQLite converter - Emmet_ - 21.11.2013

Quote:
Originally Posted by PT
Посмотреть сообщение
hum ok

but that dont say why ( the reason ) SQLite is more better than MySQL


with SQLite is possible do one UCP (in on website, you understand?)?
It's not better, it's just my personal opinion. They are both great forms of structured query languages.

MySQL is a relational database system which is ran from an external SQL server. Each query executed is sent to the SQL server and analyzed, and then you have your queries, tables and shit.

SQLite is the same thing and uses the same language and style as MySQL, but it saves in the scriptfiles folder. SQLite, unlike MySQL, doesn't require an external server this way.

AFAIK, I don't think that SQLite can be used to make a UCP, but MySQL can.

Excuse me for the misinterpretations, I'm awfully tired!


Re: INI to SQLite converter - PT - 21.11.2013

Quote:
Originally Posted by Emmet_
View Post
It's not better, it's just my personal opinion. They are both great forms of structured query languages.

MySQL is a relational database system which is ran from an external SQL server. Each query executed is sent to the SQL server and analyzed, and then you have your queries, tables and shit.

SQLite is the same thing and uses the same language and style as MySQL, but it saves in the scriptfiles folder. SQLite, unlike MySQL, doesn't require an external server this way.

AFAIK, I don't think that SQLite can be used to make a UCP, but MySQL can.

Excuse me for the misinterpretations, I'm awfully tired!
oh THANKS

you took all my little questions

Thanks man

i will use SQLite xD


Re: INI to SQLite converter - ***Niko*** - 21.11.2013

Well i've just done this and no bugs for now everything fine,i don't understand SQLite it's my first time i use it but i will read about it more so i can understand it.

Thanks Emmet and all good peoples here who work hard for all no*bs like me here

Regards,
With all love

( )


Re: INI to SQLite converter - JesterlJoker - 09.01.2017

Is there still anyway that this links be updated? Or does anyone still have a link of this file?

If there is then can I ask for a link?

Thank you in advance


Respuesta: INI to SQLite converter - Marshmello - 08.06.2017

Does anyone have the link of the converter?


Re: INI to SQLite converter - Gammix - 08.06.2017

I had a similar filterscript:
https://sampforum.blast.hk/showthread.php?pid=3804185#pid3804185