$ mysql.start (só na caelum)
$ mysql -u root
mysql> create database mydatabase;
Languages
7,194 gist results
7,194 gist results
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pymysql as mysql | |
| byte = [] | |
| ## Fill in SQL DB parameters | |
| db = mysql.connect(user=, passwd=, db=, port=) | |
| c=db.cursor() | |
| ## Fill in SQL SELECT statement | |
| c.execute("SELECT FROM WHERE LIMIT") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # python bot that scrapes and organise release changes of mysql | |
| from bs4 import BeautifulSoup | |
| import requests | |
| # url="https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-"+ +"".html" | |
| f=open("new.txt",'w') | |
| for i in range(14,27): | |
| print("-"*100) | |
| f.write("-"*100) | |
| print("MySQL Release 5.7."+str(i)) | |
| f.write("MySQL Release 5.7."+str(i)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import mysql.connector | |
| from mysql.connector import Error | |
| from mysql.connector import errorcode | |
| # $ sudo pip install mysql-connector | |
| # $ sudo pip install mysql-connector-python-rf | |
| # Python Program to Check database connection in MySQL | |
| try: | |
| connection = mysql.connector.connect(host='localhost', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import mysql.connector | |
| connect = mysql.connector.connect(user='arcra', password='xxxxx', host='localhost', database='arcra') | |
| cursor = connect.cursor() | |
| # INSERT | |
| query = "INSERT INTO ..") | |
| cursor.execute(query) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # example queries, will be different across different db platform | |
| firebird_extract = (''' | |
| SELECT fbd_column_1, fbd_column_2, fbd_column_3 | |
| FROM fbd_table; | |
| ''') | |
| firebird_insert = (''' | |
| INSERT INTO table (column_1, column_2, column_3) | |
| VALUES (?, ?, ?) | |
| ''') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| import facebook | |
| # 引入 MySQL 模組 | |
| import MySQLdb | |
| # 連接到 MySQL | |
| db = MySQLdb.connect(host="x.x.x.x", user="yume", passwd="xxxx", db="xData",charset="utf8",use_unicode = True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: cp936 -*- | |
| import MySQLdb | |
| class MysqldbHelper: | |
| # 获取数据库连接 | |
| def getCon(self): | |
| try: | |
| conn = MySQLdb.connect(host='localhost', user='mjy', passwd='123', db='python', port=3306, charset='utf8') | |
| return conn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import MySQLdb | |
| conn = MySQLdb.connect(host=\"localhost\", user=\"root\", passwd=\"nobodyknow\", db=\"amit\") | |
| cursor = conn.cursor() | |
| stmt = \"SELECT * FROM overflows\" | |
| cursor.execute(stmt) | |
| # Fetch and output | |
| result = cursor.fetchall() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FIND_BY_SQL = "findBySql" # 根据sql查找 | |
| COUNT_BY_SQL = "countBySql" # 自定义sql 统计影响行数 | |
| INSERT = "insert" # 插入 | |
| UPDATE_BY_ATTR = "updateByAttr" # 更新数据 | |
| DELETE_BY_ATTR = "deleteByAttr" # 删除数据 | |
| FIND_BY_ATTR = "findByAttr" # 根据条件查询一条记录 | |
| FIND_ALL_BY_ATTR = "findAllByAttr" #根据条件查询多条记录 | |
| COUNT = "count" # 统计行 | |
| EXIST = "exist" # 是否存在该记录 |