@@ -29,7 +29,7 @@ def __init__(self, *args, **kwargs): # pylint: disable=unused-argument
2929 self ._table = None
3030 self ._connection = None
3131 self .table = kwargs .get ("table" , "pymodbus" )
32- self .database = kwargs .get ("database" , "sqlite:///pymodbus.db " )
32+ self .database = kwargs .get ("database" , "sqlite:///:memory: " )
3333 self ._db_create (self .table , self .database )
3434
3535 def __str__ (self ):
@@ -93,6 +93,8 @@ def _db_create(self, table, database):
9393 :param database: The database uri to use
9494 """
9595 self ._engine = sqlalchemy .create_engine (database , echo = False )
96+ self ._connection = self ._engine .connect ()
97+ self ._connection .execute ('ATTACH DATABASE \' :memory:\' AS pymodbus_db;' )
9698 self ._metadata = sqlalchemy .MetaData (self ._engine )
9799 self ._table = sqlalchemy .Table (
98100 table ,
@@ -102,8 +104,7 @@ def _db_create(self, table, database):
102104 sqlalchemy .Column ("value" , sqltypes .Integer ),
103105 UniqueConstraint ("type" , "index" , name = "key" ),
104106 )
105- self ._table .create (checkfirst = True )
106- self ._connection = self ._engine .connect ()
107+ self ._table .create (self ._engine )
107108
108109 def _get (self , type , offset , count ): # pylint: disable=redefined-builtin
109110 """Get.
0 commit comments