Añadido zxdb.py
This commit is contained in:
@@ -34,7 +34,7 @@ for opt, arg in opts:
|
|||||||
opt_list = "yes"
|
opt_list = "yes"
|
||||||
elif opt in ("-m", "--manufacturer"):
|
elif opt in ("-m", "--manufacturer"):
|
||||||
opt_manufacturer = arg
|
opt_manufacturer = arg
|
||||||
elif opt == '-d':
|
elif opt in ("-d", "--dat"):
|
||||||
opt_dat = arg
|
opt_dat = arg
|
||||||
elif opt in ("-c", "--copy"):
|
elif opt in ("-c", "--copy"):
|
||||||
opt_copy = "yes"
|
opt_copy = "yes"
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import mysql.connector
|
||||||
|
from mysql.connector import errorcode
|
||||||
|
|
||||||
|
config = {
|
||||||
|
'user': 'root',
|
||||||
|
'password': 'unJEPimbJddHP8',
|
||||||
|
'host': '127.0.0.1',
|
||||||
|
'database': 'zxdb',
|
||||||
|
'raise_on_warnings': True
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
cnx = mysql.connector.connect(**config)
|
||||||
|
except mysql.connector.Error as err:
|
||||||
|
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
|
||||||
|
print("Something is wrong with your user name or password")
|
||||||
|
elif err.errno == errorcode.ER_BAD_DB_ERROR:
|
||||||
|
print("Database does not exist")
|
||||||
|
else:
|
||||||
|
print(err)
|
||||||
|
|
||||||
|
|
||||||
|
cursor = cnx.cursor()
|
||||||
|
|
||||||
|
query = ("SELECT id, title FROM entries "
|
||||||
|
"WHERE id BETWEEN %s AND %s")
|
||||||
|
|
||||||
|
id_start = 1950
|
||||||
|
id_end = 1980
|
||||||
|
|
||||||
|
cursor.execute(query, (id_start, id_end))
|
||||||
|
|
||||||
|
for (id, title) in cursor:
|
||||||
|
print("{} ({})".format(title, id))
|
||||||
|
|
||||||
|
cursor.close()
|
||||||
|
cnx.close()
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user