Joke Collection Website - Blessing messages - General interface method for Python to access different types of databases
General interface method for Python to access different types of databases
Effect after implementation: 1. Safe. Interface information encapsulation is convenient for confidential management; 2. reuse. Disposable packaging, permanent reuse; 3. Get started quickly. It is convenient for students who are not familiar with python and data call and can only use simple sql, saving time and effort.
We take MySQL, MongoDB and Influx DB as examples to define interface methods, and then encapsulate them into 1 general methods.
mysql_get(sql,db):
mongo_get(sql,db):
intrusion _ get(SQL,db):
As you can see, the parameters of the above function call are sql and db. We add another parameter db_type, which will construct a general method to call the above database.
Similarly, other types of databases can be added to this general framework, including but not limited to all types of relational, key-value and time-series databases.
- Related articles
- How to type the number of intervals in the middle of English names with keyboard?
- What is indiscriminate bombing?
- What is the tariff introduction of the old Guangdong Double 4G Chat King?
- Chinese New Year greeting leaders' short messages.
- It is a sign of dreaming about someone texting me.
- How to turn up the sound of Meizu mobile phone
- Will Jiangxi Post notify the results of the written examination of school recruitment?
- Gitzo court prosecution warning letter. Is it true or not? I received a warning letter at home today. Will I go to jail?
- Li Feier Angelababy's short message record
- The mobile phone automatically sends information to 12 1 14, as shown in the figure, how to do it and how to solve it, thank you.