[python] Adding extension to geckodriver with selenium

Webdriver I am using firefox hence I am downloading geckodriver to work with selenium. To set up the webdriver in the code do this: from selenium import webdriver driver_path = r"E:\webdriver\firefox\geckodriver.exe" driver = webdriver.Firefox(executable_path=driver_path) Install extension To install an extension to the webdriver for each instance do this: buster = r"E:\webdriver\firefox\buster_captcha_solver_for_humans-1.0.1-an+fx.xpi" driver.install_addon(buster, temporary=True) On every … Continue reading [python] Adding extension to geckodriver with selenium

[python]SQLAlchemy usage example

This is an aggregation on how to use SQLAlchemy to create a database, table and insert data into the created table. Refer to this tutorial on how to use SQLAlchemy. from sqlalchemy_utils import database_exists, create_database from sqlalchemy import create_engine, Column, Integer, String from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker url = "mysql+pymysql://username:password@database_address/database_name" # Create … Continue reading [python]SQLAlchemy usage example

[python]VARCHAR requires a length on dialect mysql with sqlalchemy

I remember I did not need to define the varchar length, however I encountered this error: sqlalchemy.exc.CompileError: (in table 'test_table', column 'name'): VARCHAR requires a length on dialect mysql So I would need to define the length of varchar with the String object from SqlAlchemy. meta = MetaData() """ Define the table. The below is … Continue reading [python]VARCHAR requires a length on dialect mysql with sqlalchemy

[python]Create database if not exists with sqlalchemy

This is an example of using SQLAlchemy module to create database if it does not exist otherwise connect to the requested database. from sqlalchemy import create_engine from sqlalchemy_utils import database_exists, create_database from getpass import getpass """ database url is dialect+driver://username:password@db_address/db_name To connect to mysql/mariadb, pymysql module is required to install. The purpose of using SqlAlchemy … Continue reading [python]Create database if not exists with sqlalchemy

Mariadb for remote access

The default service is bind to localhost:3306 to allow remote client to access to the mariadb, modify this file: /etc/mysql/mariadb.conf.d/50-server.cnf, comment the bind-address and add the two new lines as shown below: Then restart the mariadb service: sudo systemctl restart mariadb

[python]Hand made cryptography with XOR method.

ord function is to convert a character to its equivalent integer representation. chr function is to convert the integer to its character representation. random.choice() method randomly picks a character from a series of characters to form a string of N length, this is the key for encryption and decryption. A message is taken from user's … Continue reading [python]Hand made cryptography with XOR method.