Python: How to manage multiple user?
<p>I have a list of users IDs and each user ID has a lot of friends IDs. I want to write a program to send message to user's friend.  So how to manage these information ? I think I should using 1 single file and write this Json format into file:</p>

<pre><code>{'id_user':1, 'id_friend': 123}
{'id_user':1, 'id_friend': 124}
{'id_user':1, 'id_friend': 125}
{'id_user':1, 'id_friend': 126}
{'id_user':2, 'id_friend': 222}
{'id_user':2, 'id_friend': 223}
{'id_user':2, 'id_friend': 224}
{'id_user':2, 'id_friend': 225} 
...
</code></pre>

<p>If i use this way, after that, the file will have few dozen million rows.
So, What is best way to manage these users ? What type of database I should use ?  Thank you !</p>

<p>I hope my answer is not too biased...</p>

<p>Depending on what else you want to accomplish, there are several options:</p>

<ul>
<li>In standard library you have <a href="https://docs.python.org/3/library/sqlite3.html" rel="nofollow">sqlite3</a> which is a relational database engine (which can handle large amounts of rows quite well)</li>
<li>There are other relational database engines like mysql for which python libraries exist (most have better performance for huge datasets that sqlite)</li>
<li>There is <a href="https://pypi.python.org/pypi/ZODB" rel="nofollow">ZODB</a> (tutorial on <a href="http://www.zodb.org/en/latest/" rel="nofollow">zodb.org</a>) which is an object-database engine (you can actually use it as an ORM, too)</li>
<li>There are object-relational mappers (ORM) like <a href="http://www.sqlalchemy.org/" rel="nofollow">sqlalchemy</a> or the one included in <a href="https://www.djangoproject.com/" rel="nofollow">django</a> that can help you build databases.</li>
</ul>

<p>You should have a look at the <a href="https://wiki.python.org/moin/DatabaseProgramming/" rel="nofollow">Python Wiki</a> which providess deeper info about that</p>

python json database file dictionary