Spaces:
Sleeping
Sleeping
File size: 3,179 Bytes
d57efd6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"work_directory = r\"D:\\Project_Multimedika\\Projek_2\\fullstack_summarizer_and_bot_development\\backend\"\n",
"os.chdir(work_directory)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2024-10-02 10:13:26,616 DEBUG sqlalchemy.pool.impl.QueuePool Created new connection <_mysql.connection open to 'mysql-1034fd4a-hamzahibnuarman-ad3d.e.aivencloud.com' at 0000014BA7A87210>\n",
"2024-10-02 10:13:26,782 INFO sqlalchemy.engine.Engine SELECT DATABASE()\n",
"2024-10-02 10:13:26,782 INFO sqlalchemy.engine.Engine [raw sql] ()\n",
"2024-10-02 10:13:26,960 INFO sqlalchemy.engine.Engine SELECT @@sql_mode\n",
"2024-10-02 10:13:26,974 INFO sqlalchemy.engine.Engine [raw sql] ()\n",
"2024-10-02 10:13:27,059 INFO sqlalchemy.engine.Engine SELECT @@lower_case_table_names\n",
"2024-10-02 10:13:27,060 INFO sqlalchemy.engine.Engine [raw sql] ()\n",
"2024-10-02 10:13:27,235 DEBUG sqlalchemy.pool.impl.QueuePool Connection <_mysql.connection open to 'mysql-1034fd4a-hamzahibnuarman-ad3d.e.aivencloud.com' at 0000014BA7A87210> checked out from pool\n",
"Connection successful!\n",
"2024-10-02 10:13:27,235 DEBUG sqlalchemy.pool.impl.QueuePool Connection <_mysql.connection open to 'mysql-1034fd4a-hamzahibnuarman-ad3d.e.aivencloud.com' at 0000014BA7A87210> being returned to pool\n",
"2024-10-02 10:13:27,238 DEBUG sqlalchemy.pool.impl.QueuePool Connection <_mysql.connection open to 'mysql-1034fd4a-hamzahibnuarman-ad3d.e.aivencloud.com' at 0000014BA7A87210> rollback-on-return\n"
]
}
],
"source": [
"from sqlalchemy import create_engine\n",
"\n",
"SQLALCHEMY_DATABASE_URL = (\n",
" \"mysql://avnadmin:AVNS_St9zLKGWwfGKvC2yMCz@mysql-1034fd4a-hamzahibnuarman-ad3d.e.aivencloud.com:10707/summarizer\"\n",
")\n",
"engine = create_engine(\n",
" SQLALCHEMY_DATABASE_URL,\n",
" echo=True,\n",
" echo_pool=\"debug\",\n",
" connect_args={\n",
" \"ssl\": {\n",
" 'sslmode': \"REQUIRED\",\n",
" \"ca\": \"ca.pem\", # Update this path to your CA certificate\n",
" # Other SSL options can be added here\n",
" }\n",
" }\n",
")\n",
"\n",
"# Test connection\n",
"try:\n",
" with engine.connect() as connection:\n",
" print(\"Connection successful!\")\n",
"except Exception as e:\n",
" print(\"Error connecting to the database:\", str(e))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "fullstack",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|