You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With connection string cockroachdb://maxroach:maxroach@roach-0:26257/movr?sslcert=/certs/client.maxroach.crt&sslkey=/certs/client.maxroach.key&sslmode=verify-full&sslrootcert=/certs/ca.crt&port=26257
The following code works in Jupyter once sqlalchemy-cockroachdb is installed.
# handling transaction error that we talk about in the blog and requiring to reconnect# https://docs.sqlalchemy.org/en/13/orm/tutorial.html# the entire sqlalchemy tutorialimportsqlalchemyfromsqlalchemyimportcreate_enginefromsqlalchemy.ormimportsessionmakerfromcockroachdb.sqlalchemyimportrun_transactionfromsqlalchemy.ext.declarativeimportdeclarative_basefromsqlalchemyimportColumn, Stringimportgetpasspassword=getpass.getpass()
sql_engine=create_engine('cockroachdb://maxroach:'+password+'@roach-0:26257/movr?sslcert=/certs/client.maxroach.crt&sslkey=/certs/client.maxroach.key&sslmode=verify-full&sslrootcert=/certs/ca.crt&port=26257')
Base=declarative_base()
classVehicles(Base):
__tablename__='vehicles'city=Column(String, primary_key=True)
type=Column(String)
session=sessionmaker(bind=sql_engine)
defrun_select(session):
forrowinsession.query(Vehicles.city, Vehicles.type).all():
print(row.city, row.type)
run_transaction(session, run_select)
The text was updated successfully, but these errors were encountered:
With connection string
cockroachdb://maxroach:maxroach@roach-0:26257/movr?sslcert=/certs/client.maxroach.crt&sslkey=/certs/client.maxroach.key&sslmode=verify-full&sslrootcert=/certs/ca.crt&port=26257
I get the following error
Can't load plugin: sqlalchemy.dialects:cockroachdb
The following code works in Jupyter once
sqlalchemy-cockroachdb
is installed.The text was updated successfully, but these errors were encountered: