Or use it to find and download high-quality how-to PowerPoint ppt presentations with illustrated or animated slides that will teach you how to do something new, also for free. Or use it to upload your own PowerPoint slides so you can share them with your teachers, class, students, bosses, employees, customers, potential investors or the world. Or use it to create really cool photo slideshows - with 2D and 3D transitions, animation, and your choice of music - that you can share with your Facebook friends or Google circles. Nothing other than having peewee ( pip install peewee) is required.That's all free as well!įor a small fee you can get the industry's best online privacy or publicly promote your presentations and slide shows with top rankings. It makes my day for small projects or stand alone apps, Where using big tools like SQLAlchemy or Django is overkill : import peeweeĭb = MySQLDatabase('jonhydb', user='john', passwd='megajonhy')īook = Book(author="me", title='Peewee is cool') It's a very lite ORM, really easy and fast to setup then use. I recently discovered another jewel in the Python world: peewee. I strongly advise you to use it: your life is going to be much easier. The most famous ORM in the Python community is SQLAlchemy. Once you know how it works, You may want to use an ORM to avoid writing SQL manually and manipulate your tables as they were Python objects. You will have to look at the documentation. Of course, there are thousand of possibilities and options this is a very basic example. # print all the first cell of all the rows It will letĬur.execute("SELECT * FROM YOUR_TABLE_NAME") Then it is just like using any other package : #!/usr/bin/pythonĭb = nnect(host="localhost", # your host, usually localhost This is not mandatory, But it will prevent me from answering 3 or 4 other questions in this post if something goes wrong. (You can use sudo apt-get install python-mysqldb (for debian based distros), yum install MySQL-python (for rpm-based), or dnf install python-mysql (for modern fedora distro) in command line to download.)įor Mac, you can install MySQLdb using Macport.Īfter installing, Reboot. Please note MySQLdb only supports Python 2.įor Windows user, you can get an exe of MySQLdb.įor Linux, this is a casual package (python-mysqldb). The most used package to do so is MySQLdb but it's hard to install it using easy_install. Unlike PHP, Only the SQLite driver is installed by default with Python. You must install a MySQL driver before doing anything. If you have stored procedures, you can copy them afterwards:Ĭonnecting to MYSQL with Python 2 in three steps If that is the case, use a traditional way to clone a database and then drop the old one: If some table has a trigger, it cannot be moved to another database using above method (will result Trigger in wrong schema error). If your database has no password, remove the -u username -ppassword part. There is no space between the option -p and the password.OR for table in `mysql -u root -ppassword -s -N -e "use old_db show tables from old_db "` do mysql -u root -ppassword -s -N -e "use old_db rename table old_db.$table to new_db.$table " done You will need to adjust the permissions after that.įor scripting in a shell, you can use either of the following: mysql -u username -ppassword old_db -sNe 'show tables' | while read table \ĭo mysql -u username -ppassword -sNe "rename table old_db.$table to new_db.$table" done For InnoDB, the following seems to work: create the new empty database, then rename each table in turn into the new database: RENAME TABLE old_db.table TO new_db.table
0 Comments
Leave a Reply. |