Raised This Month: $51 Target: $400
 12% 

SQLite and MySQL


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Obada
Senior Member
Join Date: Dec 2014
Location: Abu Dhabi
Old 01-23-2015 , 08:05   SQLite and MySQL
Reply With Quote #1

I have a simple question.

If I have a plugin which uses MySQL to store data, Can I make the plugin use SQLite instead of MySQL without rewriting it?

If Yes, what should I do so I can make it run using SQLite.
If No, How should I make a plugin using MySQL, use SQLite instead of MySQL.


I know it may seem stupid question, but I'm dying on finding an answer, I've searching many times on MySQL and SQLite but couldn't find the answer that I want.

Thank you.
Obada is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-23-2015 , 08:50   Re: SQLite and MySQL
Reply With Quote #2

Just a matter to select the wanted driver. API is the same.

SQL_SetAffinity("sqlite") or SQL_SetAffinity("mysql")

Now about autoloading module, depending what you want to do.
If you want to load only sqlite module, you need to do:
Code:
#pragma defclasslib sqlx sqlite
#include <sqlx>
if you want to load both module mysql and sqlite, so to change driver anytime, then:
Code:
#include "sqlx"
#pragma defclasslib sqlite sqlite
__________________

Last edited by Arkshine; 01-23-2015 at 08:51.
Arkshine is offline
Obada
Senior Member
Join Date: Dec 2014
Location: Abu Dhabi
Old 01-23-2015 , 08:57   Re: SQLite and MySQL
Reply With Quote #3

What will happen if both modules ran at the same time?

I mean will there be a higher CPU Usage?

And By the way, I should edit the plugin and write SQL_SetAffinity("sqlite") instead of SQL_SetAffinity("mysql")?

And as I know, SQLite doesn't require a external database. Am I right?
Obada is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-23-2015 , 09:22   Re: SQLite and MySQL
Reply With Quote #4

Nothing happens until you use natives in a plugin, and depending affinity, it will do stuff either in mysql or sqlite module. Both modules share the same API, and SQL_SetAffinity basically just allows you to switch module.

You don't explain really what you want to do, but if you want to change "mysql" to "sqlite", yes, just a matter to change what you say, and adding #pragma (the first) to make sqlite be autoloaded.

Yes, SQLite is local.
__________________
Arkshine is offline
Obada
Senior Member
Join Date: Dec 2014
Location: Abu Dhabi
Old 01-23-2015 , 10:04   Re: SQLite and MySQL
Reply With Quote #5

Here is the plugin that is using MySQL
Spoiler


Like if I switched to SQLite, I don't need a mysql database no more?

If so, I have some data on my mysql database, is there any possible way to transfer it to sqlite database?

Thank you!
Obada is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-29-2015 , 11:46   Re: SQLite and MySQL
Reply With Quote #6

Database will be stored locally, probably in amxmodx/data/sqlite/.

About your datas, no idea, maybe you need a converter, such as : http://www.sqlite.org/cvstrac/wiki?p=ConverterTools
__________________
Arkshine is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode