+ 3

How to access data from database from within Python

Most of the application need to access data from some database. How can we get and also be able to update data in a database automatically from within the python code

9th Oct 2016, 12:56 AM
Rohit Kumar
5 Respuestas
+ 2
x = raw_input ('Write here: ') with open('file.txt', 'a') as f: f.write (x) f.close () print 'Done !!'
9th Oct 2016, 10:03 AM
Eric john
Eric john - avatar
+ 1
I am talking about some database like MySql, postgres etc and not a text file named database.txt
9th Oct 2016, 10:08 AM
Rohit Kumar
+ 1
you must use python-mysql module to MySQL for example. you can Download it with pip: pip install python-mysql
9th Oct 2016, 8:04 PM
bryan freire
bryan freire - avatar
0
x = open("Database.txt", 'r') x.write("Hello World") close("Database.txt")
9th Oct 2016, 9:41 AM
Jrester Mester
Jrester Mester - avatar
0
writing into files ? or are you talking about sqlite3 ??
9th Oct 2016, 10:01 AM
Eric john
Eric john - avatar