At work, you often encounter the need to import data from a developer to a MySQL database, one of which is in CSV format and is imported as follows:Create the appropriate tablemysql>usekevin;databasechangedmysql>createtablegeopc_places ( ->isovarchar (2) NOTNULL,-> Countryvarchar (notnull,->languagevarchar) (2) Notnull,->idbigint (NOTNULL,) ->region1varchar, ->region2varchar (,) ->region3varchar (+), ->reg
This article mainly introduces the PHP programming implementation of the CSV file import MySQL database method, involving PHP file reading, conversion, database connection, insert and other related operations skills, the need for friends can refer to the next
Specific as follows:
config.db.php content is as follows;
index.php content is as follows:
insertdb.php content is as follows:
The above
There are more than 500 CSV files. To import SQL databases, the database fields are the same as the file fields,
How to Write batch import statements.
Declare @ dir sysname, @ cmd nvarchar (max );Set @ dir = 'C :/';
Create Table # TMP (filename nvarchar (1024 ));Set @ cmd = n' dir "'+ @ dir +' *. CSV"/B'Insert # TMP e
This code is used to import and export DataTable files in xml, excel, and csv files. Record the code for future use.
Be sure to import the excel file and add a reference to Microsoft. Office. Interop. Excel 11.0.
Default. aspx. cs File
Using System;Using System. Collections. Generic;Using System. Linq;Using System. Web;Using System. Web. UI;Using System. Web. UI.
Sometimes, when writing a program, the background requires that a large amount of data be imported into the database. For example, the computer examination result query and phone book data are generally stored in excel, in this case, we can export the data to a csv file, and then use the following program to import data to the database in batches in the background.
The following are the main program parts:
Recently been busy in the laboratory, did not properly update the blog, in the process of grasping the package, encountered a lot of problems.Because I often use Wireshark to export the capture information to a CSV file, here's a simple mark about 2 ways to import/export a CSV file to a database:A. Simple, but slightly slower way to use Navicat for MySQLto
1. Import data from DataGridView into a CSV file
Public static bool dataGridViewToCSV(DataGridView dataGridView)
{
If (dataGridView.Rows.Count == 0)
{
MessageBox.Show("No data to export!", "Prompt", MessageBoxButtons.OK, MessageBoxIcon.Information);
Return false;
}
SaveFileDialog saveFileDialog = new SaveFileDial
will be . csv format of file import Oracle in the databaseThe first of these methods1. Select tool --- text importer650) this.width=650; "Width=" 554 "height=" 346 "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd; "alt=" Spacer.gif "/>2 . Select the data selection owner and table to Oracle. 650) this.wi
MySQL provides a tool for importing and exporting databases. However, sometimes we only need to import and export data from a single table, such as importing and exporting CSV files. In this case, you can use the MySQL Automatic Command to import and export data.
The export syntax is as follows:
SELECT * FROM [TABLE]
Into outfile '[FILE]';
Or
SELECT * FROM [TAB
Tag: coded head close resolves ACS har write DMI ImportFirst, be prepared to download a Javacsv.jar rack packagepublic void Readecsv () {try { ArrayListString cell = csvlist.get (row) [0]; You can specify the fetch content by obtaining the data in column No. 0 of Row row System.out.println("姓名:"+cell) } }catch(Exception ex){ System.out.println(ex); } }/**
Writing to a
| | 0 | 0 |0 |+-----+-----+--------+--------+------+--------+------------+-------------+-----------+----------+-------+------------------------+-------+--------+-----+---------+----------+------+---------+------+-----+--------+---------+-------+-----+---------+-------------+--------------+---------------------------+-----------------------+1 row in Set (0.00 sec)There's only one piece of data in this table, and now I'm exporting a CSV file that only
When writing a program when the background requirements to import a large number of data into the database, such as computer test results of the query, phone book data are generally stored in Excel, when we can export data into a CSV file, and then through the following program can be in the background batch import data into the database.
The following are just
Label:Transferred from: http://blog.chinaunix.net/uid-23284114-id-3196638.html The MYSQL LOAD Data infile command can import a CSV flat file into a database.Under Linux:
LOAD DATA INFILE '/home/test/dump/ip_location.csv '
Into TABLE ip_location
CHARACTER SET UTF8
Fields TERMINATED by ', ' enclosed by ' ";
--character Set:mysql Character Set, must add, eliminate garbled trouble--
The examples in this article describe the import and export classes of PHP implementation CSV files. Share to everyone for your reference. as follows:
I hope this article will help you with your PHP programming.
CVS file import mysql database command:
The code is as follows
Copy Code
Set names UTF8;LOAD DATA local INFILE ' c:\\resource.csv 'into TABLE ResourceFIELDS terminated by ""LINES terminated by ' \ r \ n '(Title,singer);
FIELDS terminated by----field terminating characterOptionally enclosed by----envelope characterLINES terminated by----line terminator
Export data for a period of time to CVS:
code i
1. Start the H2 database does not open the browser window (default is open)
2. Database creation SQL adds support for bigdecimal types, H2 databases do not support BigDecimal types by default:
SQL code
Copy Code code as follows:
CREATE TABLE test (ID int (one), Charge BigDecimal (12))
SQL code
Copy Code code as follows:
CREATE TABLE test (ID int (one), Charge BigDecimal (12))
3. Import database scripts by passing para
This article mainly introduces how PHP imports MSSQL data to MYSQL, and lists two instances to import MSSQL data to MYSQL. It is a very practical technique, has some reference value and needs
This article mainly introduces how PHP imports MSSQL data to MYSQL, and lists two instances to
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.