def test_connect():
    print("Standard Connection")

    try:
        # Connect to the DCRIS database with an option file
        conn = Connect("dcris.txt")
        # Get the connection cursor object
        cursor = conn.cursor
        # Define a SQL query
        sql = "SELECT * FROM keyword"
        # Execute the query from the connection cursor
        cursor.execute(sql)
        # Print the column names from the query result
        print("Columns:")
        print(cursor.column_names)
        # Get and print the contents of the query results (raw results)
        rows = cursor.fetchall()
        print("Row count: {}".format(cursor.rowcount))

        print("Data:")
        for row in rows:
            print(row)
        # Close the Connect object
        conn.close()
    except Exception as e:
        print(str(e))
Ejemplo n.º 2
0
'''
Created on 2019 M03 8

@author: liux8275
'''
from asgn03 import keyword_member_count
from Connect import Connect

v1 = 13

conn = Connect("dcris.txt")

print("keyword_id is None(sorted by keyword description)")
rows = keyword_member_count(conn)
for row in rows:
    print(row)
print("\n")

print("keyword_id is {}(sorted by keyword description)".format(v1))
rows = keyword_member_count(conn, keyword_id=v1)
for row in rows:
    print(row)
print("\n")

conn.close()