Jump to content

from plain-text to mysql-db: how to store a triple / array?


Maze

Recommended Posts

hello dear php-experts,

 

well i want to do some data-saving in the next few days.  i have some data amount to store in a mysql-db.

well i am pretty sure this is a easy question for php-freaks

 


the question is: from plain-text to mysql-db: how to store a triple / array?

how to store this data into a mysql-db

have a dataset of 10 000 lines:

{'data_1': 'data_2', 'data_3': 'data_4', 'data_5': 'data_6', 'data_7': 'data_8'}
    
    
    
 how to store this dataset into the mysql db ?  
    

love to hear from you

greetings
 

hello dear guru

 

many thanks for the quick answer.

 

well each line is a new data-chunk or - in python language a triple.

 

 

eg like so:    data = { 'url':alk, 'name':name, 'cname':capname }
 

 

hope this may clear up a bit. - in case i need to provide more information - just let me know.

 

have a great  day

Create a table "whatever" (where whatever is a meaningful name for the data) and load the data into it. Once it is in a table you can manipulate further if required.

CREATE TABLE `whatever` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `url` varchar(255) DEFAULT NULL,
  `name` varchar(45) DEFAULT NULL,
  `cname` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`)
)

With the exception of the single quotes instead of double quotes, each line looks as though it is json encoded, so you could loop through each line, decode and insert into the table.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.