TurnKey Linux Virtual Appliance Library

How can I connect my Python or C# application to Virtual box MySQL?

jagerfield's picture
  • Hi,

I am a student and I need to load the database tables with data scraped from html websites. Could someone please inform me on how I can connect to the Mysql on Virtual box?

I have had used xeround database before and managed to connect to it using their example.



Thank you


Alon Swartz's picture

For Python I'd recommend SQLAlchemy

A while back I needed to pull and crunch some data from a MySQL database in Python, and I found SQLAlchemy very flexible.

To install (ipython is not required by very very useful):

apt-get update
apt-get install python-sqlalchemy python-mysqldb ipython

The docs are very good, but for example (replace the stuff in bold):

import sqlalchemy

conn = "mysql://root:password@appliance-ip/database"
db = sqlalchemy.create_engine(conn)
metadata = sqlalchemy.MetaData(db)

table = sqlalchemy.Table(tablename, metadata, autoload=True)
query = table.select()
rs = query.execute()
for row in rs:
    print row

Hope the above helps...

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)