[Include] INI to SQLite converter
#1

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:
  • file[] - The name of the file you wish to convert.
  • db[] - The database you would like to store the row into.
  • table[] - The table you would like to store the row into.
  • custom_field[] - Adds a custom field upon conversion (example: "Username").
  • custom_value[] - Assigns a value to the custom value (example: playername).
  • create_columns - Automatically create the columns in the database.
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
Reply
#2

This... is... FUCKIN' Awesome!
Thank you veryyyy much.
Reply
#3

That's brilliant...
Reply
#4

epic,good work man
Reply
#5

can i ask one thing?

you think SQLite is more better than MySQL?

@ Topic

nice work

+REP
Reply
#6

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
Reply
#7

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
Reply
#8

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*).
Reply
#9

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?)?
Reply
#10

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!
Reply
#11

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
Reply
#12

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

( )
Reply
#13

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
Reply
#14

Does anyone have the link of the converter?
Reply
#15

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


Forum Jump:


Users browsing this thread: 1 Guest(s)