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
2 Answers 2
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
yassin
6,7478 gold badges36 silver badges40 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
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
jonescb
23k8 gold badges50 silver badges42 bronze badges
Comments
default