Skip to content

Commit 4a86e5d

Browse files
committed
complete 0002
1 parent 33d5a04 commit 4a86e5d

File tree

3 files changed

+471
-0
lines changed

3 files changed

+471
-0
lines changed

Jimmy66/0002/0002.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
import mysql.connector
5+
6+
#从文件中读取信息
7+
def file_read(filename):
8+
with open(filename,'r') as f:
9+
lines = f.readlines()
10+
for n in range(0,200):
11+
lines[n] = lines[n].strip()
12+
return lines
13+
14+
#存入数据库
15+
def mysql_write():
16+
lines = file_read('result.txt')
17+
conn = mysql.connector.connect(user='root', password='password', database='test', use_unicode=True) #密码自行修改为自用密码
18+
cursor = conn.cursor()
19+
cursor.execute('create table promo_code (id int(3) primary key, number varchar(8))')
20+
for n in range(0,200):
21+
cursor.execute('insert into promo_code (id, number) values (%s, %s)', [n+1, lines[n]])
22+
conn.commit()
23+
cursor.close()
24+
conn.close()
25+
print "finish"
26+
27+
if __name__ == '__main__':
28+
mysql_write()

Jimmy66/0002/promo_code.sql

Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
-- phpMyAdmin SQL Dump
2+
-- version 3.4.11.1deb2+deb7u1
3+
-- http://www.phpmyadmin.net
4+
--
5+
-- 主机: localhost
6+
-- 生成日期: 2015 年 02 月 15 日 15:02
7+
-- 服务器版本: 5.5.40
8+
-- PHP 版本: 5.4.36-0+deb7u3
9+
10+
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
11+
SET time_zone = "+00:00";
12+
13+
14+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
15+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
16+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
17+
/*!40101 SET NAMES utf8 */;
18+
19+
--
20+
-- 数据库: `test`
21+
--
22+
23+
-- --------------------------------------------------------
24+
25+
--
26+
-- 表的结构 `promo_code`
27+
--
28+
29+
CREATE TABLE IF NOT EXISTS `promo_code` (
30+
`id` int(3) NOT NULL,
31+
`number` varchar(8) DEFAULT NULL,
32+
PRIMARY KEY (`id`)
33+
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
34+
35+
--
36+
-- 转存表中的数据 `promo_code`
37+
--
38+
39+
INSERT INTO `promo_code` (`id`, `number`) VALUES
40+
(1, '06221205'),
41+
(2, '85531344'),
42+
(3, '10747373'),
43+
(4, '40887544'),
44+
(5, '61712875'),
45+
(6, '83813324'),
46+
(7, '43648825'),
47+
(8, '30840323'),
48+
(9, '36832211'),
49+
(10, '01105618'),
50+
(11, '13410375'),
51+
(12, '65468385'),
52+
(13, '55683113'),
53+
(14, '68867155'),
54+
(15, '24545317'),
55+
(16, '64626102'),
56+
(17, '20728343'),
57+
(18, '06812487'),
58+
(19, '46831163'),
59+
(20, '43211742'),
60+
(21, '74116167'),
61+
(22, '84722574'),
62+
(23, '42777526'),
63+
(24, '06821521'),
64+
(25, '46006164'),
65+
(26, '75747227'),
66+
(27, '01811788'),
67+
(28, '25124141'),
68+
(29, '88402648'),
69+
(30, '27814287'),
70+
(31, '71176283'),
71+
(32, '34852241'),
72+
(33, '13232158'),
73+
(34, '55172318'),
74+
(35, '76560208'),
75+
(36, '34562718'),
76+
(37, '14470566'),
77+
(38, '66472235'),
78+
(39, '43043486'),
79+
(40, '82587857'),
80+
(41, '31165481'),
81+
(42, '61282076'),
82+
(43, '51888112'),
83+
(44, '63434568'),
84+
(45, '00332440'),
85+
(46, '16208350'),
86+
(47, '82726762'),
87+
(48, '76348604'),
88+
(49, '67626647'),
89+
(50, '40874847'),
90+
(51, '32004853'),
91+
(52, '23201687'),
92+
(53, '76141208'),
93+
(54, '76652005'),
94+
(55, '43027814'),
95+
(56, '70487088'),
96+
(57, '51100542'),
97+
(58, '75636082'),
98+
(59, '11274755'),
99+
(60, '68062563'),
100+
(61, '47757087'),
101+
(62, '88845773'),
102+
(63, '27218807'),
103+
(64, '02881740'),
104+
(65, '80688110'),
105+
(66, '62527342'),
106+
(67, '88376682'),
107+
(68, '52136864'),
108+
(69, '32768130'),
109+
(70, '64831121'),
110+
(71, '01660656'),
111+
(72, '68284636'),
112+
(73, '03844432'),
113+
(74, '53287038'),
114+
(75, '33517722'),
115+
(76, '78753670'),
116+
(77, '72513462'),
117+
(78, '80243861'),
118+
(79, '80740322'),
119+
(80, '32666043'),
120+
(81, '14767271'),
121+
(82, '31362170'),
122+
(83, '54722211'),
123+
(84, '67673546'),
124+
(85, '71530765'),
125+
(86, '30244212'),
126+
(87, '77576738'),
127+
(88, '86657202'),
128+
(89, '84444178'),
129+
(90, '88468247'),
130+
(91, '54184117'),
131+
(92, '56661765'),
132+
(93, '84005730'),
133+
(94, '08121831'),
134+
(95, '27275157'),
135+
(96, '57340616'),
136+
(97, '10544260'),
137+
(98, '22873056'),
138+
(99, '78722771'),
139+
(100, '11734138'),
140+
(101, '73146352'),
141+
(102, '20243567'),
142+
(103, '10067846'),
143+
(104, '18647840'),
144+
(105, '36105120'),
145+
(106, '10127745'),
146+
(107, '34721127'),
147+
(108, '78540741'),
148+
(109, '50541616'),
149+
(110, '32316886'),
150+
(111, '17477764'),
151+
(112, '68557540'),
152+
(113, '61833782'),
153+
(114, '14836884'),
154+
(115, '13205258'),
155+
(116, '30135127'),
156+
(117, '06784272'),
157+
(118, '06035717'),
158+
(119, '57765256'),
159+
(120, '16304861'),
160+
(121, '35258452'),
161+
(122, '06857838'),
162+
(123, '65270618'),
163+
(124, '81846635'),
164+
(125, '81831780'),
165+
(126, '37150676'),
166+
(127, '83437771'),
167+
(128, '52254508'),
168+
(129, '42765761'),
169+
(130, '13213803'),
170+
(131, '58634373'),
171+
(132, '80018333'),
172+
(133, '80162586'),
173+
(134, '34380717'),
174+
(135, '65865270'),
175+
(136, '08286300'),
176+
(137, '24416804'),
177+
(138, '44766425'),
178+
(139, '21210230'),
179+
(140, '16060305'),
180+
(141, '55578384'),
181+
(142, '01312373'),
182+
(143, '41407715'),
183+
(144, '76451227'),
184+
(145, '47103278'),
185+
(146, '60401033'),
186+
(147, '33811504'),
187+
(148, '58456258'),
188+
(149, '03256286'),
189+
(150, '08403105'),
190+
(151, '64435036'),
191+
(152, '51277430'),
192+
(153, '74503246'),
193+
(154, '40023773'),
194+
(155, '24817724'),
195+
(156, '88612034'),
196+
(157, '07788457'),
197+
(158, '86656864'),
198+
(159, '72513618'),
199+
(160, '05212708'),
200+
(161, '25161048'),
201+
(162, '18440578'),
202+
(163, '28626680'),
203+
(164, '21455352'),
204+
(165, '18247878'),
205+
(166, '56710751'),
206+
(167, '40024360'),
207+
(168, '02676631'),
208+
(169, '71176541'),
209+
(170, '45347211'),
210+
(171, '72637627'),
211+
(172, '30713084'),
212+
(173, '71061801'),
213+
(174, '54546710'),
214+
(175, '73405660'),
215+
(176, '70303522'),
216+
(177, '26720541'),
217+
(178, '62457276'),
218+
(179, '43350522'),
219+
(180, '66346162'),
220+
(181, '36376106'),
221+
(182, '86125656'),
222+
(183, '22880566'),
223+
(184, '16325646'),
224+
(185, '88307733'),
225+
(186, '08081038'),
226+
(187, '48314863'),
227+
(188, '40044423'),
228+
(189, '87133380'),
229+
(190, '88580362'),
230+
(191, '84376574'),
231+
(192, '41720582'),
232+
(193, '53641143'),
233+
(194, '55035648'),
234+
(195, '72176747'),
235+
(196, '32600634'),
236+
(197, '57622861'),
237+
(198, '46441808'),
238+
(199, '51540837'),
239+
(200, '65628570');
240+
241+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
242+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
243+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

0 commit comments

Comments
 (0)