What is the maximum number of connections for a SQLite3 database?

后端 未结 3 1012
既然无缘
既然无缘 2020-12-07 00:25

What is the maximum number of connections for a SQLite3 database?

Why can\'t I use it for very big websites, for example with 3 million users?

3条回答
  •  长情又很酷
    2020-12-07 00:47

    Under different system, this value may be different, the python test code:

    import sqlite3
    import sys
    
    # connect to multiple databases
    def multi_connect(conn_num):
        dbs = []
        for i in range(0, conn_num):
            try:
                con = sqlite3.connect(str(i) + '.db')
            except Exception as e:
                print('connect to %d.db failed' % i)
                sys.exit(-1)
    
    
    # multiple connections to single database
    def multi_connect2(conn_num):
        db_name = 'x.db'
        conns = []
        for i in range(0, conn_num):
            try:
                conn = sqlite3.connect(db_name)
            except Exception as e:
                print('connect failed at %d' % i)
                sys.exit(-1)
    

    Under ubuntu, the failed count is 1021, you can test it under different OS.

提交回复
热议问题