SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 10/04/2019, 12:37 PM   #1
Dolke
Little Clucker
 
Join Date: Jul 2015
Posts: 12
Reputation: 0
Question How to insert large amount of data to sql table?

Hello.

I have one problem.How can I save a lot of data in sql table with INSERT? I need to insert about 50 columns in table when player is registered to server.
Dolke is offline   Reply With Quote
Old 10/04/2019, 12:49 PM   #2
JesterlJoker
Huge Clucker
 
Join Date: Apr 2015
Location: Cagayan de Oro, Philippines
Posts: 275
Reputation: 27
Default Re: How to insert large amount of data to sql table?

using transactions
__________________

Testers are welcome just slide into my DM's.
JesterlJoker is offline   Reply With Quote
Old 10/04/2019, 01:11 PM   #3
Gforcez
Gangsta
 
Gforcez's Avatar
 
Join Date: Jul 2010
Location: The Netherlands.
Posts: 723
Reputation: 390
Default Re: How to insert large amount of data to sql table?

Quote:
Originally Posted by Dolke View Post
Hello.

I have one problem.How can I save a lot of data in sql table with INSERT? I need to insert about 50 columns in table when player is registered to server.
Maybe start by looking what you're inserting. Maybe there's a better solution on a database level. What are you inserting when a player registers?
__________________

Gforcez is online now   Reply With Quote
Old 10/04/2019, 01:15 PM   #4
Logic_
Banned
 
Join Date: Jun 2015
Posts: 1,514
Reputation: 305
Default Re: How to insert large amount of data to sql table?

50 fucking what? You really need to do your database organization and normalization if you've so much fields to put data for.

An example would be such as weapons data that is often saved in the players table should be saved separately, the houses and businesses should be loaded from their own table regardless if it's purchased or not by the player, etc.

You should show us the table so we can help you out
Logic_ is offline   Reply With Quote
Old 10/04/2019, 05:20 PM   #5
Dolke
Little Clucker
 
Join Date: Jul 2015
Posts: 12
Reputation: 0
Default Re: How to insert large amount of data to sql table?

Here is the code for create table.I created table with DB Browser for SQLite and I want to save all of these when player registers (insert in table with values)

https://pastebin.com/98F8v1nT
Dolke is offline   Reply With Quote
Old 12/04/2019, 06:33 PM   #6
Dolke
Little Clucker
 
Join Date: Jul 2015
Posts: 12
Reputation: 0
Default Re: How to insert large amount of data to sql table?

BUMP !
Dolke is offline   Reply With Quote
Old 12/04/2019, 07:55 PM   #7
khRamin78
Huge Clucker
 
Join Date: Jun 2015
Posts: 311
Reputation: 30
Default Re: How to insert large amount of data to sql table?

try to optimize your sql database !
see this method

if all is ok then you need to send big query to your database i think there wont be any problems using high string characters to sql server use like string[2048];
and you have to use << \ >> in while to avoid compiler error in pawno just like this sample code

PHP Code:
mysql_format(Handel,query,sizeof(query),"UPDATE accounts SET \
            Bsqlid = %d,Hsqlid = %d,Rentsqlid = %d,LastLogin = '%s',\
            Vehicle1 = %d,Vehicle2 = %d,Wanted = %d,Food = %f,Water = %f,\
            Score = %d,Money = %d,BankMoney = %d,Ecash = %d,ProIncome = %d,\
etc 
khRamin78 is offline   Reply With Quote
Old 12/04/2019, 08:55 PM   #8
BlackBank
Gangsta
 
Join Date: Dec 2010
Location: The Netherlands
Posts: 524
Reputation: 437
Default Re: How to insert large amount of data to sql table?

Why you don't set a default value for all the columns you don't need to INSERT data for? Like for example 'admin', it can be default 0 when a player registers, and so there are more fields.
BlackBank is offline   Reply With Quote
Old 12/04/2019, 09:37 PM   #9
Gforcez
Gangsta
 
Gforcez's Avatar
 
Join Date: Jul 2010
Location: The Netherlands.
Posts: 723
Reputation: 390
Default Re: How to insert large amount of data to sql table?

Quote:
Originally Posted by BlackBank View Post
Why you don't set a default value for all the columns you don't need to INSERT data for? Like for example 'admin', it can be default 0 when a player registers, and so there are more fields.
This is your solution right here. The values you want to set and doesn't have a default value (username, password and what more) you can just add in the INSERT statement.
__________________

Gforcez is online now   Reply With Quote
Old 13/04/2019, 02:25 AM   #10
khRamin78
Huge Clucker
 
Join Date: Jun 2015
Posts: 311
Reputation: 30
Default Re: How to insert large amount of data to sql table?

Quote:
Originally Posted by BlackBank View Post
Why you don't set a default value for all the columns you don't need to INSERT data for? Like for example 'admin', it can be default 0 when a player registers, and so there are more fields.
Quote:
Originally Posted by Gforcez View Post
This is your solution right here. The values you want to set and doesn't have a default value (username, password and what more) you can just add in the INSERT statement.
anyway he should use large query when saving player global data with that amount of data
khRamin78 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
ConvertFFS bugged with a large amount of objects - any other conversion software? Aerotactics Server Support 2 30/04/2014 03:54 AM
Executing Create Table/ INSERT INTO DavidLuango Scripting Help 2 30/11/2013 10:44 PM
Does not insert into a Table Neil. Scripting Help 2 01/03/2013 03:39 PM
How to insert data from another table inside a table in one query Roel Scripting Help 2 21/09/2012 03:43 PM
Can a large amount of cars cause lag? Robert_Crawford Help Archive 11 15/10/2010 09:21 PM


All times are GMT. The time now is 01:33 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.