Framework for python with sqlite - python

i am new in python.before this i done some work in php with codeigniter framework.
now i want to develop website using python and sqlite3.
so which framework will you suggest me.
i also want to know IDE for sqlite.

Do you mean something similar to sqliteman or dbeaver? These are not not IDEs for SQLite, but instead, are GUI interfaces. There are more here: http://www.google.com/search?&q=sqlite+gui
3rd link down is another stack overflow question: What are good open source GUI SQLite database managers?
For Python web frameworks, a very popular full-stack framework is the Django Project

Check out web2py. It's a feature-rich full-stack framework, but it's also very easy to set up, learn, and use. It requires no installation or configuration, has no dependencies, and includes its own web server and web-based IDE/administrative interface (see demo). If you download the binary version for Windows or Mac, it even includes its own Python interpreter (so you don't need to have Python installed).
The database abstraction layer (DAL) works with 10 different database backends, including SQLite. It doesn't include its own SQLite IDE, though it does include a database administrative interface called appadmin, which allows you to view all database tables; view, insert, update, and delete records within each table; and import/export tables to CSV. You can also import and export the entire database to CSV. (Note, these features work for all database backends, not just SQLite.)
You will probably also find that you don't really need an IDE for SQLite when using web2py because the DAL takes care of everything for you. You specify all of your data models using the DAL syntax, and then the DAL automatically creates the SQLite database, creates all tables, and handles migrations when you changes your models.
If you have any questions, there's a friendly and responsive mailing list that will provide lots of help.

Related

Database migrations in Flask without SQLAlchemy

Is there any library or tool to perform database migrations in python without SQLAlchemy? I am using a PostgreSQL database and the queries are raw SQL. I use psycopg2 for the database connection.
In short, "yes."
There are numerous possibilities. The one you choose will depend on doing some homework to determine which one best suits your needs.
https://github.com/amacneil/dbmate
https://pypi.org/project/yoyo-migrations/
https://pypi.org/project/alembic/
Suggest when asking questions that can be answered with a google search, to be more specific about your situation, to help answerers to understand why Google couldn't answer your question in the first page of results.
If you can bring yourself to do your db migrations outside of the CLR, I'd strongly recommend considering FlyWay. It has been around forever, it's supported by RedGate, and the community version is free and open source. It has built-in support for all the major db platforms and installs like any other utility you'd use. For a Python app you'd do all of your db migrations via shell scripts or process calls instead of directly in the code.
My team settled on this tech because:
Yoyo is pretty immature and buggy for us
We don't use SQLAlchemy's OR framework
Alembic's syntax and framework seems pretty heavyweight for us
Under FlyWay's model we just write SQL scripts and check them into a directory. It's really lightweight.
It's been proven to work nicely in clustered environments
Give it a look.

Django to create and change mysql database for learning purposes

I am leaning Python programming language. I have no problems with Python. I read Python official docs, and I can write small programs in Python. I want to familiarize myself with mysql database because it is useful in learning software development concepts. I've installed mysql database and Django on my computer. I have Ubuntu 14.04 and python 3.4 installed. I've configured Django settings to use mysql database. I tested Django connection to mysql db and all things work properly.
I am a complete newbie with web development. I didn't create my own website and I didn't start developing any web application.
My purpose currently is to master creation of mysql database and tables, making changes/migrations/queries, using Django models and Python.
Is it reasonable/possible to use Django ORM for work with mysql database without simultaneous development of a web application/local application? As I've said, I don't have my own website. I want just to try using mysql and Django together on my computer in order to get deeper knowledge as to Django and mysql in this respect.
My final purpose is development in Python, including work with mysql database.
Mysql without Python and Django is of no use for me.
If you want to learn and use MySQL, then start without anything above it - no Django, no ORM, not even a Python script. Learn to configure your mysql server (the server process I mean - doesn't have to be on a distinct computer), to work with the command-line mysql client (database creation, tables creations / modifications, adding/updating/deleting rows, and, most important, doing simple and complex queries).
While you're at it, learn about proper relational data modeling (normalisations etc) so you fully understand how to design your schemas.
Once you're confortable with this, spend some time (should be quite fast at this point) learning to do the same things from python scripts with your python's version mysql connector.
Then if you want to learn web development and Django, well go for it. The ORM is quite easy to use when you already have a good understanding of what happens underneath, so by that time you shouldn't have much problems with this part. What you'll still have to learn are the HTTP protocol (trying to do web programming without understanding the HTTP protocol is like trying to win a car race without knowing how to drive a car - it's not technically impossible but it might end up being very painful experience), then front-end stuff (html/css/javascript) and finally the views / templates parts of Django (which should be easy once you know HTTP and html).
You can of course jump right in into Django, but you will probably fight with way too many concepts at once and end up spending twice more time to figure out how everything works and why it works that way.

Self-contained python application with GUI and charts

I have some data in an SQLite database and serve it through JSON objects to an HTML app via AJAX calls and chart it using D3.js. I would like to replicate the same functionality locally (MS Windows is fine) in a self-contained application. It would be a super simple app, just a few form controls, a chart and a table, querying a local file-based database. As for it being self-contained - I'd like to ship an .exe file and an .sqlite file to someone with no need to install python, numpy, matplotlib, sqlite or anything on the target computer.
I'd like to it to be quite future-proof, so I'd rather stay away from experimental/alpha libraries and build it using more proven technologies that have had longer term support. It seems that PyInstaller is the way to go in terms of self-containing, but developers seem to be quite divided when it comes to GUI options.
The question is then: What's the industry standard to build future self-contained GUI apps in Python? One which would include SQLite access and charting. Thanks!
Python itself includes the sqlite module since version 2.5:
https://docs.python.org/2/library/sqlite3.html
So regardless of which Python GUI Toolkit you go with, you already have that functionality built in to Python. There are several options to choose from when it comes to Python GUI toolkits. If you want a toolkit that can handle theming / skinning, then you may want to look at PyQt or even Kivy. The only GUI toolkit that uses the actual widgets of each major OS that I know of is wxPython. All the others draw their own widgets, albeit some of them do it so well that you'd be hard-pressed to tell the difference (i.e. PyQt).
All three of these projects are stable and are currently being developed, although wxPython's development is much slower than the others mentioned here. wxPython and PyQt both have widgets that allow you to load web pages.
However if all you want to do is serve web pages locally, then you might be better served using a Python web framework such as Django or Flask. You could run these locally pretty easily and view your content via the user's browser. The exe could launch them locally and call Python's webbrowser module to launch the default browser to a local URL.

using mysql instead of sqlite3

im working on python application that requiring database connections..I had developed my application with sqlite3 but it start showing the error(the database is locked).. so I decided to use MySQL database instead.. and it is pretty good with no error..
the only one problem is that I need to ask every user using my application to install MySQL server on his pc (appserv for example) ..
so can I make mysql to be like sqlite3 apart of python lib. so I can produce a python script can be converted into exe file by the tool pyInstaller.exe and no need to install mysql server by users???
update:
after reviewing the code I found opened connection not closed correctly and work fine with sqllite3 ..thank you every body
It depends (more "depends" in the answer).
If you need to share the data between the users of your application - you need a mysql database server somewhere setup, your application would need to have an access to it. And, the performance can really depend on the network - depends on how heavily would the application use the database. The application itself would only need to know how to "speak" with the database server - python mysql driver, like MySQLdb or pymysql.
If you don't need to share the data between users - then sqlite may be an option. Or may be not - depends on what do you want to store there, what for and what do you need to do with the data.
So, more questions than answers, probably it was more suitable for a comment. At least, think about what I've said.
Also see:
https://stackoverflow.com/questions/1009438/which-database-should-i-use-for-my-desktop-application
Python Desktop Application Database
Python Framework for Desktop Database Application
Hope that helps.
If your application is a stand-alone system such that each user maintains their own private database then you have no alternative to install MySQL on each system that is running the application. You cannot bundle MySQL into your application such that it does not require a separate installation.
There is an embedded version of MySQL that you can build into your application (thanks, Carsten, in the comments, for pointing this out). More information is here: http://mysql-python.blogspot.com/. It may take some effort to get this working (on Windows you apparently need to build it from source code) and will take some more work to get it packaged up when you generate your executable, but this might be a MySQL solution for you.
I've just finished updating a web application using SQLite which had begun reporting Database is locked errors as the usage scaled up. By rewriting the database code with care I was able to produce a system that can handle moderate to heavy usage (in the context of a 15 person company) reliably still using SQLite -- you have to be careful to keep your connections around for the minimum time necessary and always call .close() on them. If your application is really single-user you should have no problem supporting it using SQLite -- and that's doubly true if it's single-threaded.

Multi developer environment python and sqlalchemy

I'm currently exploring using python to develop my server-side implementation. I've decided to use SQLAlchemy for database stuff.
What I'm not currently to sure about is how it should be set up so that more than one developer can work on the project. For the code it is not a problem but how do I handle the database modifications? How do the users sync databases and how should potential data be set up? Should/can each developer use their own sqlite db for development?
For production postgresql will be used but the developers must be able to work offline.
You can use Alembic to manage your DB structure. Keep your migrations under version control in order to ensure that it's easy for developers to keep in sync with changes.
As regards data itself, you can either work with a set of fixtures, or you could write some Fabric commands to import/export Postgres dumps, which you could also keep under version control if necessary – depending on data size, you may not want to keep a large uncompressed SQL dump under version control (though it will compress well using git or hg), however. This aspect of your question depends on the size of your development team, and the size of your database.
Make sure you have a python programs or programs to fill databases with test data from scratch. It allows each developer to work from different starting points, but also test with the same environment.

Categories

Resources