-
Notifications
You must be signed in to change notification settings - Fork 0
Commiting mysql-connection code for review #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,17 @@ | ||
#!/usr/bin/python | ||
|
||
hostname = '127.0.0.1' | ||
username = 'root' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as previous comment |
||
password = 'redhat' | ||
database = 'mysql' | ||
#socket ='/tmp/mysql-master5520.sock' | ||
|
||
# Simple routine to run a query on a database and print the results: | ||
def Query( conn ) : | ||
print "Printing user and hosts from the box\n" | ||
cur = conn.cursor() | ||
cur.execute( "SELECT user,host FROM user" ) | ||
# for row in cur : | ||
row = cur.fetchone() | ||
while row is not None: | ||
print row[0], row[1] | ||
row = cur.fetchone() | ||
# print (row) | ||
|
||
def index ( conn1 ) : | ||
cur = conn1.cursor() | ||
|
@@ -25,7 +20,6 @@ def index ( conn1 ) : | |
for row in cur : | ||
print (row) | ||
|
||
|
||
def data_big ( conn3 ) : | ||
cur = conn3.cursor() | ||
print "\n\nFind biggest db" | ||
|
@@ -40,8 +34,7 @@ def data_dist ( conn4 ) : | |
for row in cur : | ||
print (row) | ||
|
||
print "======Using pymysql========" | ||
print " " | ||
|
||
import pymysql as my | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
connect = my.connect( host=hostname, user=username, passwd=password, db=database ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can this be made to use a .my.cnf file ? |
||
Query( connect ) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this parameters dynamic ? Use a getopts like tool to parse arguments.