Re: MySQL with Python
Yes you can. There are libraries available in python to make this happen. Read this for a starter http://dev.mysql.com/usingmysql/python/ Regards, Anurag On Oct 15, 2012 10:53 AM, রুদ্র ব্যাণার্জী bnrj.ru...@gmail.com wrote: Dear friends, I am starting a project of creating a database using mySQL(my first project with database). I went to my institute library and find that, all books are managing mySQL with perl and php I am new to python itself and gradually loving it. I mostly use it as an alternative of shell-script. Since learning a new language for every new project is not possible(its self assigned project, generally in free time), can I do a mySQL with python? if yes, can you kindly suggest a book/reference on this? -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQL with Python
On Tue, Oct 16, 2012 at 12:45 AM, রুদ্র ব্যাণার্জী bnrj.ru...@gmail.com wrote: Dear friends, I am starting a project of creating a database using mySQL(my first project with database). I went to my institute library and find that, all books are managing mySQL with perl and php I am new to python itself and gradually loving it. I mostly use it as an alternative of shell-script. Since learning a new language for every new project is not possible(its self assigned project, generally in free time), can I do a mySQL with python? if yes, can you kindly suggest a book/reference on this? It's definitely possible. As far as I know, though, there's no inbuilt support, so you'll need an add-on module. What platform are you running on? On Debian Linux, for instance, you can simply apt-get install python-mysqldb. But you may wish to consider using PostgreSQL instead. It's a generally better database engine than MySQL, and is equally well supported: http://wiki.python.org/moin/PostgreSQL Actually, to be quite honest, I'm surprised there's no module in the Python stdlib for either of the above. Possibly because there are several competing options. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQL with Python
On 12-10-15 06:45 AM, রুদ্র ব্যাণার্জী wrote: if yes, can you kindly suggest a book/reference on this? There are a few different ways to connect to MySQL, two of which are: For reference on connecting and querying MySQL through mysql-python, take a read through http://mysql-python.sourceforge.net/MySQLdb.html. Another solution is to use SQLAlchemy (http://www.sqlalchemy.org/). The ORM abstracts a lot of the tedious SQL queries out for you and allows you to concentrate more on your application's logic. -- Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQL with Python
On Tue, 2012-10-16 at 01:01 +1100, Chris Angelico wrote: But you may wish to consider using PostgreSQL instead. Thanks, as I am very much new in database thing, I am not very aware of the options I have. But in my library, I did not found any thing on PostgreSQL. Though, I will google its support as well, can you kindly let me know if this is well documented. I can see there mailing list is quite active. So that may not be a problem though. -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQL with Python
On Tue, Oct 16, 2012 at 1:47 AM, রুদ্র ব্যাণার্জী bnrj.ru...@gmail.com wrote: On Tue, 2012-10-16 at 01:01 +1100, Chris Angelico wrote: But you may wish to consider using PostgreSQL instead. Thanks, as I am very much new in database thing, I am not very aware of the options I have. But in my library, I did not found any thing on PostgreSQL. Though, I will google its support as well, can you kindly let me know if this is well documented. I can see there mailing list is quite active. So that may not be a problem though. Postgres itself: http://www.postgresql.org/ I posted a link to some Python-PGSQL libraries in my previous post. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQL with Python
Don't worry about what book you have (or don't have) in your Library..And let this not dictate your technology stack. PostgreSQL is one of the popular choice and you will never be short of documentation...Just Google and you will find lot of helpful tutorials... Regards, Anurag On Mon, Oct 15, 2012 at 10:47 AM, রুদ্র ব্যাণার্জী bnrj.ru...@gmail.comwrote: On Tue, 2012-10-16 at 01:01 +1100, Chris Angelico wrote: But you may wish to consider using PostgreSQL instead. Thanks, as I am very much new in database thing, I am not very aware of the options I have. But in my library, I did not found any thing on PostgreSQL. Though, I will google its support as well, can you kindly let me know if this is well documented. I can see there mailing list is quite active. So that may not be a problem though. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQL with Python
In article mailman.2233.1350328857.27098.python-l...@python.org, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: For routine database /access/ (that is, someone has created the database user account that will be used), MySQLdb is the Python adapter to connect to the server. For using THAT, you basically need to know SQL (MySQL's flavor in particular), along with understanding the DB-API 2 specification (PEP-249) with the MySQLdb documentation (which explains any limitations or specifics; see http://mysql-python.sourceforge.net/ ) Another possibility is to use some sort of ORM (Object Relational Mapper), which provides an abstraction layer on top of the raw SQL layer. Two examples are SQLAlchemy (http://www.sqlalchemy.org/) and Django (https://www.djangoproject.com/). A thread on Stack Overflow (http://stackoverflow.com/questions/53428) mentions some additional Python ORMs you might want to explore. -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQL from python - dropping a database IF EXISTS
Ah well - I turned off warnings as a solution. Its a bit f a bodge, but it works :-) Ben wrote: Can someone explain why this might be happening: parser_beta.py:129: Warning: Can't drop database 'foobar'; database doesn't exist self.cursor.execute(DROP DATABASE IF EXISTS +name) But the whole point about the IF EXISTS bit is (I thought) that it will only drop it if it exists, if it doesn't do nothing and don't throw an error. I'm using MySQL 5.024 and python 2.4.3 It still works, but the unneccesary error is annoying :-) Any ideas? Cheers, Ben -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQL from python - dropping a database IF EXISTS
Ben wrote: Ah well - I turned off warnings as a solution. Its a bit f a bodge, but it works :-) according to the documentation, the database does generate a note when you do this: http://dev.mysql.com/doc/refman/5.0/en/drop-table.html and notes can be turned off independently of warnings, it seems: http://dev.mysql.com/doc/refman/5.0/en/show-warnings.html /F -- http://mail.python.org/mailman/listinfo/python-list