Skip to content

@maxmealy
maxmealy / SQLSelectPy
Last active August 29, 2015 14:16
Python SQL SELECT
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")
@adilsaju
adilsaju / changelog_sql5_7.py
Created August 21, 2019 08:22
Python Scripts
# 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))
@devops-school
devops-school / check.py
Created July 24, 2022 12:26
Python Tutorials: Database operations using python - mysql
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',
@drshawn
drshawn / mysql_connect.py
Created June 17, 2022 03:40
[Python MySQL Connect] Python MySQL Connect Routine #Python
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)
@martinyung
martinyung / sql_queries.py
Last active January 29, 2022 14:11
python etl
# 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 (?, ?, ?)
''')
@yume190
yume190 / fb.py
Created August 31, 2014 14:37
Python MySQL
#!/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)
@thaisandre
thaisandre / mysql_python.md
Last active June 24, 2019 21:56
python + mysql

1 - conexão com mysql e python

abrindo o mysql pelo terminal do linux e criando a base dados

    $ mysql.start (só na caelum)
    
    
    $ mysql -u root
    mysql> create database mydatabase;
@mercurychs
mercurychs / python_mysql.py
Created May 3, 2017 14:30
[python mysql example 2] python mysql example2 #tags python
# -*- 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
@lambdaman2
lambdaman2 / Snipplr-29633.py
Created October 1, 2012 12:47
Python: MySQL-Python
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()
@mercurychs
mercurychs / python-mysql-util.py
Last active November 2, 2022 08:17
[python mysql example] python mysql example #tags: python, java
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" # 是否存在该记录