What is the most effective method of storing and recalling data?
<p>I've been wanting to build a pretty big project which pretty much mimics Twitter, I've just started it and have run into a little error with account creation. I was wondering what the best method of storing and recalling data is. I'm well aware I can use .txt files to do this, but then I've found it's trickier to make the program recognize the structure of the data.</p>

<pre><code>For example, the file might look like this:
acnt - twigman
pass - yellow
</code></pre>

<p>And the user creating an account might use the same name, and I would need to stop that, but I wouldn't know how to make the program know where the username starts and ends.</p>

<p>If I could use a database within the Python program, that would be a heck of a lot easier, it would mean the program can run as just one file and it would be easier to code. The program could also recognize the beginning and end of a user name without needing to write more script for it.</p>

<p>Thank you for your help.</p>

<p>Your expectations of Python are very low. That is great news because you are going to be very happy.</p>

<p>You can definitely use a database with Python. The simplest and quickest to set up as well as closest to what you described is a file database: SQLite. <a href="http://zetcode.com/db/sqlitepythontutorial/" rel="nofollow">Here</a> is a great tutorial to start.</p>

<p>If you want to stick to simpler than than, you can use the <a href="https://wiki.python.org/moin/UsingPickle" rel="nofollow">pickle module</a> or the <a href="https://docs.python.org/2/library/shelve.html" rel="nofollow">shelve module</a> to âpersistâ your data </p>

<p>Of course, once your database increases significantly in size, you can move on to MySQL or PostgreSQL or others.</p>

<p>I encourage you to check out database abstraction tools such as <a href="http://www.sqlalchemy.org/" rel="nofollow">SQLAlchemy</a> as they can make your life easier.</p>

<p>If you are building a web application, then why reinvent the wheel? Choose one from the <a href="https://wiki.python.org/moin/WebFrameworks" rel="nofollow">many Python web frameworks</a>. Some if not all of them abstract away the database so you can focus on your application and its features.</p>

python database import export