Tags: python#!/usr/bin/env python
#-*-coding:utf-8-*-
'
1, where the database environment is local database
2, the database I want to operate through Python is test_db
3 , the database has a table, table name: User
4, tables field: ID, name, address
5, where the ID field is self-increment, is also the primary key
6, because the ID field has been since, so when inserting
solved directly with an SQL statement:INSERT into TABLE (a,c) VALUES (1,3) on DUPLICATE KEY UPDATE c=c+1; And then further, batch storage also no problem, can also be processed separately:INSERT into TABLE (a,b,c) VALUES (All-in-all
),
(2,5,7),
(3,3,6),
(4,8,2) on
DUPLICATE KEY UPDATE b= VALUES (b); It's simply not convenient:#数据入库:
# D2: To be in storage dataframe, first column code, second column valu
If there is a data table A:
ID Name Title Addtime
If you need to insert an n-piece of data:
$time = time ();
$data = Array (
' name ' => ' name1 ', ' title ' => ' Title1 ', ' addtime ' => $time;
),
Array (
' name ' => ' name2 ', ' title ' => ' Title2 ', '
Tags: nbsp virtual machine selected will IMG Blog Font war TTLFirst, unpack the kettle package 1. Copy the package to the Linux system And the MySQL driver pack. 2, unpack the zip suffix package Input command:unzip/software/pdi-ce-7.0.0.0-25.zip You can delete the original package. Input command:rm-f pdi-ce-7.0.0.0-25.zip Ii. Creating databases and tables Inserting data from a text file into a dat
Tags: --Demo to combine multiple record data into one SQL INSERT statement (for MySQL) function getTpl0 (tname)--Get table fields Local T = {Tpl_pack = {"Packid", "ItemId", "' GR OUP ' "," num "," rate "," Ratetype "},} to K, V in pairs (t) does if tname = = K then return t[k] end End End--TPL = {3 813,10,0,2,0,1,1,0
function:#rand_string (n int) rand_string is the function name (n int)//The function passes an integerCreatefunctionrand_string (n INT) returns varchar (255) BeginDeclareCHARS_STR varchar (100)default' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ';DeclareRETURN_STR varchar (255)default‘‘;DeclareI intdefault0; whileI DoSet Return_str=concat (Return_str,substring (CHARS_STR, Floor(1 +Rand() *52), 1)); Set I= i +1; End while;returnReturn_str;End$$One more function.function ran
following are some usage parameters of mysqldump:
Back up database
# Mysqldump Database Name> Database Backup name
# Mysqldump-a-u username-P Password Database Name> Database Backup name
# Mysqldump-D-A -- add-drop-table-uroot-P> XXX. SQL
1. the exported structure does not export data
Mysqldump-D database name-uroot-P> XXX. SQL
2. Export data without expor
Tags: mysql BULK insert dataThe table structure is as follows650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/9E/42/wKioL1mOl66xQ0a1AAA6Sw4G6jw633.png "title=" 1.png "alt=" Wkiol1mol66xq0a1aaa6sw4g6jw633.png "/>The requirements name and password fields, which generate the following format:650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/9E/5
MySQL database problem, how to add two tables (a table, B table) in the same operation, and add the ID of B table to the A table field, B table ID automatically growcreate a stored procedure in the database, such as the name of th
Php cannot insert data into mysql source code: $ db nbsp; new nbsp; mysqli (localhost, root, 5832528); $ db- gt; select_db (books ); $ query1 nbsp; insert nbsp; into nbsp; books nbsp; values (123-45 php cannot insert data in
Reprinted from nosqlfan. view the original article
This article describes how to write common SQL statements in MySQL in MongoDB. If you are eager to try using MySQL for a long time, this simple article will help you enter the role more quickly.
Query:MySQL:Select * from userMongo:DB. User. Find ()
MySQL:Select * from user where name = 'starlil'Mongo:DB. User. Find ({'name': 'starlil '})
Insert:MySQL:Insert
MySQL table structure replication, table data migration, temporary table and view creation 1. copy only the table structure, do not copy data www.2cto.com select * into B from a where 1
Php cannot insert data into the mysql source code: $ db nbsp; = new nbsp; mysqli ("localhost", "root", "5832528 "); $ db- gt; select_db ("books"); $ query1 nbsp; = nb php cannot insert data into mysql
Source code:
$ Db = new
I use mysqli, a breath need to insert 52 records, occasionally will miss a few did not insert success, now this table 3.4M, if the table is emptied, this will not happen?
Reply to discussion (solution)
Only 53 will leak??? What kind of code ah, stick it out to seeAnother: Why not PDO?
Not a problem with the cod
There are many methods to convert an Access data table to a mysql DATA table and search for it online. However, my method seems extremely simple. Export an excel file in access and import it to mysql. Mysql's visual operation tool
It takes a lot of time for mysql to insert multiple data records.
SQL script
Select * from users;
Method 1:
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
MySQL batch insert data script
MySQL batch insert data script
#! /Bin/bashI = 1;MAX_INSERT_ROW_COUNT = $1;While [$ I-le $ MAX_INSERT_ROW_COUNT]DoMysql-uroot-proot dbname-e "insert int
MySQL learning notes-data definition table constraints, paging method summary, mysql learning notes
This article describes the data definition table constraints and paging methods of MySQL
Tags: des style blog color ar using SP data divDescribe statement:Grammar:describe table name;Simplified notation:desc Table NameAttention1. Two kinds of writing results are the same,2. You can not end with a semicolon,3. Multiple tables are not supported for simultaneous querying.Detailed structure of query table crea
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.