#!/usr/bin/env python
# encoding: utf-8  
# Date: 2018/6/24

import pymysql

username = input('username:')
password = input('password:')
conn = pymysql.connect(
    host='127.0.0.1',
    port=3306,
    user='root',
    password='123',
    db='stu_system',
    charset='utf8'
)

# 拿到游标
cursor = conn.cursor()

# 执行sql语句
if username.isdigit():
    username = int(username)
    sql = 'select * from stu_teacher where tid = %s and tname = "%s" ' % (username, password)

 rows = cursor.execute(sql)

# 防止sql注入方式

# sql = 'select * from stu_teacher where tid = %s and tname = %s '
    # rows = cursor.execute(sql, (username, password))

cursor.close()
conn.close()

if rows:
    print('success!!!')
else:
    print('xxxxxxxxxxx')

pymysql简单链接示例的更多相关文章

  1. hadoop环境安装及简单Map-Reduce示例

    说明:这篇博客来自我的csdn博客,http://blog.csdn.net/lxxgreat/article/details/7753511 一.参考书:<hadoop权威指南--第二版(中文 ...

  2. 【java开发系列】—— spring简单入门示例

    1 JDK安装 2 Struts2简单入门示例 前言 作为入门级的记录帖,没有过多的技术含量,简单的搭建配置框架而已.这次讲到spring,这个应该是SSH中的重量级框架,它主要包含两个内容:控制反转 ...

  3. Springmvc整合tiles框架简单入门示例(maven)

    Springmvc整合tiles框架简单入门示例(maven) 本教程基于Springmvc,spring mvc和maven怎么弄就不具体说了,这边就只简单说tiles框架的整合. 先贴上源码(免积 ...

  4. go与c++链接示例

    go lang与c/c++的链接示例: foo.hpp //foo.hpp #ifndef _FOO_HPP_ #define _FOO_HPP_ template<typename T> ...

  5. EasyHook远注简单监控示例 z

    http://www.csdn 123.com/html/itweb/20130827/83559_83558_83544.htm 免费开源库EasyHook(inline hook),下面是下载地址 ...

  6. Web Service简单入门示例

    Web Service简单入门示例     我们一般实现Web Service的方法有非常多种.当中我主要使用了CXF Apache插件和Axis 2两种. Web Service是应用服务商为了解决 ...

  7. Ext简单demo示例

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...

  8. GDAL中MEM格式的简单使用示例

    GDAL库中提供了一种内存文件格式--MEM.如何使用MEM文件格式,主要有两种,一种是通过别的文件使用CreateCopy方法来创建一个MEM:另外一种是图像数据都已经存储在内存中了,然后使用内存数 ...

  9. html5本地存储之localstorage 、本地数据库、sessionStorage简单使用示例

    这篇文章主要介绍了html5本地存储的localstorage .本地数据库.sessionStorage简单使用示例,需要的朋友可以参考下 html5的一个非常cool的功能,就是web stora ...

随机推荐

  1. 通过Google Custom Search API 进行站内搜索

    今天突然想把博客的搜索改为google的站内搜索,印象中google adsense中好像提高这个站内搜索的代码,但苦逼的是google adsense帐号一直审核不通过,所以只能通过google c ...

  2. while for if ---语句和编写计划任务

    关于while循环: while do done 例如 1.关于内存的实时操作: (1).vim a.sh (2).输入以下while循环 (3)../a.sh执行脚本 2.自加一的操作: (1).v ...

  3. Cassandra key说明——Cassandra 整体数据可以理解成一个巨大的嵌套的Map Map<RowKey, SortedMap<ColumnKey, ColumnValue>>

    Cassandra之中一共包含下面5种Key: Primary Key Partition Key Composite Key Compound Key Clustering Key 首先,Prima ...

  4. 【sparkSQL】DataFrame的常用操作

    scala> import org.apache.spark.sql.SparkSession import org.apache.spark.sql.SparkSession scala> ...

  5. 条款19:定义class就相当于定义一个个的内置类型

    下面的条框应该是谨记的: 1. 新的type应该如何创建与销毁 2. 对象的初始化与赋值应该有什么样的区别 3. 新type的对象如果被pass-by-value,有什么影响? 4. 什么事新type ...

  6. LeetCode OJ:Three Sum(三数之和)

    Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all un ...

  7. Spring:org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class

    很长时间没有使用Spring,Hibernate,Struts2等一些框架了,现在使用起来还是有点陌生,今天刚弄就在Tomcat在启动的时候是报的这个错误: org.springframework.b ...

  8. php实现安装程序的 安装

    install.php 只要填写数据库就可以把数据插入到数据库中,实现安装 <?php header("Content-type:text/html;charset=utf-8&quo ...

  9. Games Delphi developers play

    Original link: Games Delphi developers play   Delphi game developers are stupid people having too ma ...

  10. opencv 边界确定函数

    多边形逼近,用嘴贴切的多边形标识 void approxPolyDP(InputArray curve, OutputArray approxCurve, double epsilon, bool c ...