拼接index
import MySQLdb
import sys db = MySQLdb.connect(host="127.0.0.1", # your host, usually localhost
user="root", # your username
passwd="", # your password
db="test",
port=3312) # name of the data base # you must create a Cursor object. It will let
# you execute all the queries you need
cur = db.cursor() # Use all the SQL you like
try:
cur.execute("show create table memory_test") except MySQLdb.Error as e:
print e
sys.exit(1) # print all the first cell of all the rows for row in cur.fetchall():
ddl_statement = row[1] #print ddl_statement
line_sum = len(ddl_statement.splitlines())
if 3 >= line_sum:
sys.exit(1) line_index = 0
new_create_table_statement = ""
for ddl_statement_line in ddl_statement.splitlines():
#print(ddl_statement_line)
if line_index == line_sum - 2:
new_create_table_statement += (ddl_statement_line + ",\n")
new_create_table_statement += ("index idx_name(`name`)" + "\n")
#print ddl_statement_line
#print("index idx_name(`name`)")
else:
new_create_table_statement += (ddl_statement_line + ",\n")
line_index += 1
print new_create_table_statement
db.close()
拼接index的更多相关文章
- 产品列表页分类筛选、排序的算法实现(PHP)
一.简单的单条件查询 工作都是从简单的开始,先从最简单的单表查询开始,这个一般用在首页以及一些比较独立的页面,只需要查找几个符合条件的产品展示出来即可,可以使用分页或者不使用分页.下面这个是产品控制器 ...
- python(二)——list、字典、字符串操作
列表——list 假设一种场景,想要存班里所有同学的名字,那应该拿什么存呢? 我们可以拿一个字符串去存,例如: stus = "s1,s2,s3,s4,s5……sn" 那我们要从里 ...
- koa源码阅读[3]-koa-send与它的衍生(static)
koa源码阅读的第四篇,涉及到向接口请求方提供文件数据. 第一篇:koa源码阅读-0第二篇:koa源码阅读-1-koa与koa-compose第三篇:koa源码阅读-2-koa-router 处理静态 ...
- pandas 之 字符串处理
import numpy as np import pandas as pd Python has long been a popular raw data manipulation language ...
- 静态文件cdn自解析生成相对路径
一.场景和目标: 用户上传一个包含 index.html 的静态资源压缩包,资源内所有文件都是相互依赖的,不需要用户对内部文件内容做任何特殊处理,仅通过服务端逻辑处理达到用户访问 http: ...
- Vue项目二、vue-cli2.x脚手架搭建build文件夹及config文件夹详解
build文件夹下 build.js 'use strict' // js的严格模式 require('./check-versions')() // node和npm的版本检查 process.en ...
- 使用python拼接多张图片.二三事
前几日在博客上看到一篇“使用python拼接多张图片”的Blog[具体是能将的图片名字必须是形如xx_1.png ... xx_100.png或者xx_001.png ... xx_100.png,拼 ...
- 有了jsRender,妈妈再也不用担心我用jq拼接DOM拼接的一团糟了、页面整齐了、其他伙伴读代码也不那么费劲了
写在前面 说来也很巧, 下午再做一个页面,再普通不过的分页列表,我还是像往常一样,基于MVC环境下,我正常用PagedList.MVC AJAX做无刷新分页,这时候问题就来了,列表数据中有个轮播图用到 ...
- java.lang.IllegalArgumentException: Illegal character in query at index 261
在BaseFragment中使用了LoadingPage,而LoadingPage的联网加载使用的是AsyncHttpClient.一直报java.lang.IllegalArgumentExcept ...
随机推荐
- mongodb安装(比较全一点)
Linux下MongoDB安装和配置详解 转:https://www.cnblogs.com/pfnie/articles/6759105.html 一.创建MongoDB的安装路径 在/usr/l ...
- 跨浏览器的事件对象EventUtil
var EventUtil = function(){ /*--addHandler--*/ addHandler:function(element,type,handler){ if(element ...
- HIDU 2094
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2094 产生冠军 Time Limit: 1000/1000 MS (Java/Others) M ...
- OSTimeDlyHMSM函数
1.os_time.c里面 #if OS_TIME_DLY_HMSM_EN > 0 INT8U OSTimeDlyHMSM (INT8U hours, INT8U minutes, INT8U ...
- Oracle session相关数据字典(一)
(一)session相关视图 (1)视图 v$session v$active_session_history dba_hist_active_session_history 如果是多节点数据库,v$ ...
- oracle11g的安装与卸载
1.首先确认电脑已安装 .NET Framework3.5 2.本地计算机的安装: 参考:https://www.cnblogs.com/hoobey/p/6010804.html 3.服务器的安装: ...
- plsql误删除数据,提交事务后如何找回?
select * from tbs_rep_template as of timestamp to_timestamp('2018-07-12 14:23:00', 'yyyy-mm-dd hh24: ...
- 纯 js 让浏览器不缓存 ajax 请求
开发「bufpay.com 个人即时到账收款平台」支付页面需要用到 ajax 轮询订单的支付状态. 现在浏览器对 ajax 的缓存策略遵循 http response header 里面的缓存设置,为 ...
- 基于DCT的图片数字水印实验
1. 实验类别 设计型实验:MATLAB设计并实现基于DCT的图像数字水印算法. 2. 实验目的 了解基于DCT的图像数字水印技术,掌握基于DCT系数关系的图像水印算法原理,设计并实现一种基于DCT的 ...
- CentOS 7.x eth0
1:Test Environment [root@linux-node1 ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server rel ...