1

How to use any SQL database eg. mysql, pgsql or other except the ones Python has built-in support for?

def example():
 con= Mysql("root", blablabla)
 con->query("SELECT * bla bla bla")
....
NullUserException
85.8k31 gold badges212 silver badges239 bronze badges
asked Sep 17, 2010 at 13:59

2 Answers 2

3

What DB and what extension are you using? For sqlite3 (and any other extension compatible with DB-API 2.0) you can use something like this:

conn = sqlite3.connect('/tmp/example')
c = conn.cursor()
# Create table
c.execute('''create table stocks(date text, trans text, symbol text, qty real, price real)''')
# Insert a row of data
c.execute("""insert into stocks values ('2006-01-05','BUY','RHAT',100,35.14)""")
# Save (commit) the changes
conn.commit()
# We can also close the cursor if we are done with it
c.close()

BTW, there is no ->in Python

answered Sep 17, 2010 at 14:04
Sign up to request clarification or add additional context in comments.

Comments

0

There is a list of Python 3.x compatible packages here: http://pypi.python.org/pypi?:action=browse&c=533&show=all

All I could find was oursql and py-postgresql

answered Sep 17, 2010 at 14:10

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.