How to use _create_connection_url method in testcontainers-python

Best Python code snippet using testcontainers-python_python

testcontainer.py

Source:testcontainer.py Github

copy

Full Screen

...27 self.with_env("POSTGRES_USER", self.POSTGRES_USER)28 self.with_env("POSTGRES_PASSWORD", self.POSTGRES_PASSWORD)29 self.with_env("POSTGRES_DB", self.POSTGRES_DB)30 def get_connection_url(self):31 return super()._create_connection_url(dialect="postgresql+pg8000",32 username=self.POSTGRES_USER,33 password=self.POSTGRES_PASSWORD,34 db_name=self.POSTGRES_DB,35 port=self.port_to_expose)36def create_postgres_container(db_name, db_username, db_password, db_port):37 """38 Returns a new PortablePostgresContainer instance39 """40 log.msg(41 'testcontainers/create',42 db_name=db_name,43 db_username=db_username,44 db_port=db_port45 )...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...8def get_session(config):9 global _session10 if _session is not None:11 return _session12 url = _create_connection_url(config)13 engine = sqlalchemy.create_engine(url, poolclass=sqlalchemy.pool.NullPool, echo=False)14 _session = sqlalchemy.orm.sessionmaker()15 _session.configure(bind=engine)16 _session = _session()17 return _session18def close_connection():19 global _session20 if _session is not None:21 _session.close()22def _create_connection_url(config):23 hostname = config.get('hostname')24 port = config.get('port', '5432')25 username = config.get('username')26 password = config.get('password')27 database = config.get('database', 'mitro')28 conn = 'postgres://'29 if username:30 conn += username31 if password and username:32 conn += ':' + password33 if password or username:34 conn += '@'35 if hostname:36 conn += hostname...

Full Screen

Full Screen

oracle.py

Source:oracle.py Github

copy

Full Screen

...14 self.container_port = 152115 self.with_exposed_ports(self.container_port)16 self.with_env("ORACLE_ALLOW_REMOTE", "true")17 def get_connection_url(self):18 return super()._create_connection_url(19 dialect="oracle", username="system", password="oracle", port=self.container_port,20 db_name="xe"21 )22 def _configure(self):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run testcontainers-python automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful