Refine your search:

This is a repeat of HOWTO: query MySQL from Splunk on Linux 64bit, but that solution did not work for me. Running an Intel processor, but tried the solution with both x86 and AMD64 packages. Unlike the previous post, I do have root access. Running Splunk 4.2 on RHEL 5.5. 64bit

asked 27 Apr '11, 14:02

rgcox1's gravatar image

rgcox1
8110
accept rate: 66%


One Answer:

You my consider instead using the pymsql python module. It's pure Python, so all you need to do is stick it in the bin directory of your app under your python script, e.g. put it in $SPLUNK_HOME/etc/apps/myapplication/bin/pymysql/ and this script in $SPLUNK_HOME/etc/apps/myapplication/bin/testconnection.py:

import traceback
import pymysql
try:
    cn = pymsql.connect(host="mydbserver",port=3306,user="root",password="whatever",db="mydatabase")
    csr = cn.cursor()
    csr.execute("SELECT 1+1 FROM DUAL")

    for r in csr:
        print r
except Exception as e:
    print e
    traceback.print_exc()
link

answered 27 Apr '11, 15:01

gkanapathy's gravatar image

gkanapathy ♦
26.2k1622
accept rate: 42%

edited 27 Apr '11, 15:03

There might be some squirrellyness between Python versions on the except clause. I guess you could drop the whole try...except part for testing purposes.

(27 Apr '11, 15:03) gkanapathy ♦

it just needs to be in the python search path. the first entry in the python search path is usually the directory in which the calling script is located.

(27 Apr '11, 16:13) gkanapathy ♦

Any installation necessary, or just put the egg file in the directory?

(27 Apr '11, 16:19) rgcox1

i wouldn't use an egg file or try to install it or anything. i would just drop the source pymysql directory right into the bin folder. It's pure Python, so that should be all you need.

(27 Apr '11, 16:24) gkanapathy ♦
Post your answer
toggle preview

Follow this question

Log In to enable email subscriptions

RSS:

Answers

Answers + Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×86
×9

Asked: 27 Apr '11, 14:02

Seen: 709 times

Last updated: 27 Apr '11, 16:24

Copyright © 2005-2012 Splunk, Inc. All rights reserved.