How to insert large amount of data to sql table?
#1

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

using transactions
Reply
#3

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

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

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

BUMP !
Reply
#7

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

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

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

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

Okay I did it with default values and it works as expected but now how can I save and load player data?
Reply
#12

Search for it, search for saving and loading systems, ton of examples and tutorials.
Reply
#13

Yes I know how to save player with sqlite but if I need to save just small amount of data,but I do not know how to save large amount of data in UPDATE query
Reply
#14

Quote:
Originally Posted by Dolke
View Post
Yes I know how to save player with sqlite but if I need to save just small amount of data,but I do not know how to save large amount of data in UPDATE query
Why you need to save all data at once, if you are already saving small amount of data (when money changed etc)?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)