Git Product home page Git Product logo

conn-postgresql-cpp's Introduction

Welcome to Conn-PostgreSQL-cpp ๐Ÿ‘‹

Version

connection postgresql with pqxx (using c++)

๐Ÿ  Homepage

Author

๐Ÿ‘ค holdyounger

How to complie pqxx.lib

ๆฆ‚่ฟฐ๏ผšwindowsไธ‹็ผ–่ฏ‘libpq

๐Ÿก ๆณจๆ„1๏ผšPostgreSQL ไปŽ็‰ˆๆœฌ10ไน‹ๅŽๅฐฑๅชๆœ‰64ไฝไบ†ใ€‚ไฝฟ็”จpqxxไนŸไธ็”จ่€ƒ่™‘32ไฝ

ไฝฟ็”จ็‰ˆๆœฌ่ฏดๆ˜Ž๏ผš

  • PostGreSQL: 16.1
  • pqxx: 7.7.6

๐Ÿก ๆณจๆ„2: pqxx ไฝฟ็”จ็š„ๆ˜ฏ C++17

0x01 ๅ‰่จ€

what: The official C++ client API for PostgreSQL.

0x02 ไธ‹่ฝฝๆบ็ 

ๆบ็ ไป“ๅบ“ๆไพ›ไบ†windowsไธ‹ๅฟซ้€Ÿ็ผ–่ฏ‘libpq็š„ๆ–นๆณ•ใ€‚ไฝ†ไธๅฅฝ็”จ๏ผŒๆœฌไบบๅฐ่ฏ•ไฝ†ๆœช่ƒฝๆˆๅŠŸใ€‚

0x03 ไฝฟ็”จ cmake ็ผ–่ฏ‘ pqxx

็ผ–่ฏ‘

็ผ–่ฏ‘ pqxx ้œ€่ฆ PostGreSQL ็š„่ฟ่กŒ็Žฏๅขƒ๏ผŒๅ› ๆญค้œ€่ฆไธ‹่ฝฝไบŒ่ฟ›ๅˆถๅŒ…ๆ‰่ƒฝ็ผ–่ฏ‘ๆˆๅŠŸใ€‚ๅŽป PostgreSQL ๅฎ˜็ฝ‘ไธ‹่ฝฝๅฎ‰่ฃ…ๅŒ…ๆˆ–่€…ไบŒ่ฟ›ๅˆถๅŒ…้ƒฝๅฏไปฅใ€‚

ไธ‹่ฝฝๅฎŒๆˆๅŽ๏ผŒๅˆ†ไธค็งๆƒ…ๅ†ต๏ผŒๅฆ‚ๆžœๆ˜ฏไธ‹่ฝฝ็š„ๅฎ‰่ฃ…ๅŒ…๏ผŒๅฎ‰่ฃ… postgresql ๅŽ็›ดๆŽฅ็”จ cmake ็ผ–่ฏ‘ๅฐฑๅฏไปฅไบ†๏ผŒๅฆ‚ๆžœไธ‹่ฝฝ็š„ๆ˜ฏไบŒ่ฟ›ๅˆถๆ–‡ไปถ๏ผŒๅˆ™้œ€่ฆ้…็ฝฎcmake็š„ๅ˜้‡ๅฆ‚ไธ‹ๆ‰€็คบ๏ผŒ็›ดๆŽฅไฟฎๆ”นๆ น็›ฎๅฝ•็š„ CMakeLists.txt

cmake_minimum_required(VERSION 3.8)

file(READ VERSION VER_FILE_CONTENT)
string(STRIP ${VER_FILE_CONTENT} VER_FILE_CONTENT)

project(
    libpqxx
    VERSION ${VER_FILE_CONTENT}
    LANGUAGES CXX
)

# ๅœจ่ฟ™้‡Œๅฃฐๆ˜Ž postgresql ็š„ไบŒ่ฟ›ๅˆถๆ น็›ฎๅฝ•๏ผŒๆ นๆฎไธชไบบไธ‹ๆƒ…ๅ†ต้…็ฝฎๅณๅฏ
set(PostgreSQL_ROOT "D:\\Documents\\postgresql\\postgresql-16.1-1-windows-x64-binaries\\pgsql")

if(NOT "${CMAKE_CXX_STANDARD}")
    set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

็„ถๅŽๅฐฑๆ˜ฏไฝฟ็”จ cmake ็ผ–่ฏ‘ไบ†๏ผŒ็›ฎๅ‰ VSCode ๅ’Œ Visual Studio ้ƒฝๆ”ฏๆŒ CMake ๆ–‡ไปถ็š„็ผ–่ฏ‘๏ผŒ็›ดๆŽฅ็ผ–่ฏ‘ๅณๅฏใ€‚

่ฟ™้‡Œไฝฟ็”จ Visual Studio ็ผ–่ฏ‘ๅŽ๏ผŒไผšๅœจ out ็›ฎๅฝ•ไธ‹็”Ÿๆˆlibๆ–‡ไปถ๏ผŒๅฆ‚ไธ‹ๆ‰€็คบ๏ผš

D:\Documents\A_Source\OpenSource\libpqxx\out>tree /F
ๅท ๆœฌๅœฐ็ฃ็›˜ ็š„ๆ–‡ไปถๅคน PATH ๅˆ—่กจ
ๅทๅบๅˆ—ๅทไธบ 724D-690E
D:.
โ”œโ”€build
โ”‚  โ””โ”€x64-Debug
โ”‚      โ”‚  .ninja_deps
โ”‚      โ”‚  .ninja_log
โ”‚      โ”‚  build.ninja
โ”‚      โ”‚  CMakeCache.txt
โ”‚      โ”‚  cmake_install.cmake
โ”‚      โ”‚  CPackConfig.cmake
โ”‚      โ”‚  CPackSourceConfig.cmake
โ”‚      โ”‚  install_manifest.txt
โ”‚      โ”‚  libpqxx-config-version.cmake
โ”‚      โ”‚  libpqxx-config.cmake
โ”‚      โ”‚  libpqxx-targets.cmake
โ”‚      โ”‚  libpqxx.pc
โ”‚      โ”‚  VSInheritEnvironments.txt
โ”‚      โ”‚
โ”‚      โ”œโ”€.cmake
โ”‚      โ”‚  โ””โ”€api
โ”‚      โ”‚      โ””โ”€v1
โ”‚      โ”‚          โ”œโ”€query
โ”‚      โ”‚          โ”‚  โ””โ”€client-MicrosoftVS
โ”‚      โ”‚          โ”‚          query.json
โ”‚      โ”‚          โ”‚
โ”‚      โ”‚          โ””โ”€reply
โ”‚      โ”‚                  cache-v2-4c1f3ae5d14ffd09e2dd.json
โ”‚      โ”‚                  cmakeFiles-v1-6f2def4807820d15719b.json
โ”‚      โ”‚                  codemodel-v2-8933aef952d7508a3af3.json
โ”‚      โ”‚                  directory-.-Debug-6b54e12c0d4bd01edfca.json
โ”‚      โ”‚                  directory-include-Debug-ba96d77232f254970ce6.json
โ”‚      โ”‚                  directory-src-Debug-5d1cc30954eb9bce3508.json
โ”‚      โ”‚                  directory-test-Debug-f18be1977b403cfd1a50.json
โ”‚      โ”‚                  index-2023-11-16T09-03-01-0309.json
โ”‚      โ”‚                  target-pqxx-Debug-08c4b9d672ef282e41c8.json
โ”‚      โ”‚                  target-runner-Debug-b625a8b78dd4666c4f11.json
โ”‚      โ”‚                  toolchains-v1-3b995f712f6d6e9a85c1.json
โ”‚      โ”‚
โ”‚      โ”œโ”€CMakeFiles
โ”‚      โ”‚  โ”‚  cmake.check_cache
โ”‚      โ”‚  โ”‚  CMakeConfigureLog.yaml
โ”‚      โ”‚  โ”‚  rules.ninja
โ”‚      โ”‚  โ”‚  TargetDirectories.txt
โ”‚      โ”‚  โ”‚
โ”‚      โ”‚  โ”œโ”€3.26.4-msvc4
โ”‚      โ”‚  โ”‚  โ”‚  CMakeCXXCompiler.cmake
โ”‚      โ”‚  โ”‚  โ”‚  CMakeDetermineCompilerABI_CXX.bin
โ”‚      โ”‚  โ”‚  โ”‚  CMakeRCCompiler.cmake
โ”‚      โ”‚  โ”‚  โ”‚  CMakeSystem.cmake
โ”‚      โ”‚  โ”‚  โ”‚
โ”‚      โ”‚  โ”‚  โ””โ”€CompilerIdCXX
โ”‚      โ”‚  โ”‚      โ”‚  CMakeCXXCompilerId.cpp
โ”‚      โ”‚  โ”‚      โ”‚  CMakeCXXCompilerId.exe
โ”‚      โ”‚  โ”‚      โ”‚  CMakeCXXCompilerId.obj
โ”‚      โ”‚  โ”‚      โ”‚
โ”‚      โ”‚  โ”‚      โ””โ”€tmp
โ”‚      โ”‚  โ”œโ”€CMakeTmp
โ”‚      โ”‚  โ”œโ”€Export
โ”‚      โ”‚  โ”‚  โ””โ”€d6b66e93f8212dd1f00debf9f6654819
โ”‚      โ”‚  โ”‚          libpqxx-targets-debug.cmake
โ”‚      โ”‚  โ”‚          libpqxx-targets.cmake
โ”‚      โ”‚  โ”‚
โ”‚      โ”‚  โ”œโ”€pkgRedirects
โ”‚      โ”‚  โ””โ”€ShowIncludes
โ”‚      โ”‚          foo.h
โ”‚      โ”‚          main.c
โ”‚      โ”‚          main.obj
โ”‚      โ”‚
โ”‚      โ”œโ”€include
โ”‚      โ”‚  โ”‚  cmake_install.cmake
โ”‚      โ”‚  โ”‚
โ”‚      โ”‚  โ”œโ”€CMakeFiles
โ”‚      โ”‚  โ””โ”€pqxx
โ”‚      โ”‚          config-internal-compiler.h
โ”‚      โ”‚          config-internal-libpq.h
โ”‚      โ”‚          config-public-compiler.h
โ”‚      โ”‚          config_cmake.h.in
โ”‚      โ”‚
โ”‚      โ”œโ”€src
โ”‚      โ”‚  โ”‚  cmake_install.cmake
โ”‚      โ”‚  โ”‚  pqxx.lib
โ”‚      โ”‚  โ”‚
โ”‚      โ”‚  โ””โ”€CMakeFiles
โ”‚      โ”‚      โ””โ”€pqxx.dir
โ”‚      โ”‚              array.cxx.obj
โ”‚      โ”‚              binarystring.cxx.obj
โ”‚      โ”‚              blob.cxx.obj
โ”‚      โ”‚              connection.cxx.obj
โ”‚      โ”‚              cursor.cxx.obj
โ”‚      โ”‚              encodings.cxx.obj
โ”‚      โ”‚              errorhandler.cxx.obj
โ”‚      โ”‚              except.cxx.obj
โ”‚      โ”‚              field.cxx.obj
โ”‚      โ”‚              largeobject.cxx.obj
โ”‚      โ”‚              notification.cxx.obj
โ”‚      โ”‚              params.cxx.obj
โ”‚      โ”‚              pipeline.cxx.obj
โ”‚      โ”‚              pqxx.pdb
โ”‚      โ”‚              result.cxx.obj
โ”‚      โ”‚              robusttransaction.cxx.obj
โ”‚      โ”‚              row.cxx.obj
โ”‚      โ”‚              sql_cursor.cxx.obj
โ”‚      โ”‚              strconv.cxx.obj
โ”‚      โ”‚              stream_from.cxx.obj
โ”‚      โ”‚              stream_to.cxx.obj
โ”‚      โ”‚              subtransaction.cxx.obj
โ”‚      โ”‚              time.cxx.obj
โ”‚      โ”‚              transaction.cxx.obj
โ”‚      โ”‚              transaction_base.cxx.obj
โ”‚      โ”‚              util.cxx.obj
โ”‚      โ”‚              version.cxx.obj
โ”‚      โ”‚              wait.cxx.obj
โ”‚      โ”‚
โ”‚      โ”œโ”€test
โ”‚      โ”‚  โ”‚  cmake_install.cmake
โ”‚      โ”‚  โ”‚  CTestTestfile.cmake
โ”‚      โ”‚  โ”‚  runner.exe
โ”‚      โ”‚  โ”‚  runner.ilk
โ”‚      โ”‚  โ”‚  runner.pdb
โ”‚      โ”‚  โ”‚
โ”‚      โ”‚  โ””โ”€CMakeFiles
โ”‚      โ”‚      โ””โ”€runner.dir
โ”‚      โ”‚          โ”‚  embed.manifest
โ”‚      โ”‚          โ”‚  intermediate.manifest
โ”‚      โ”‚          โ”‚  manifest.rc
โ”‚      โ”‚          โ”‚  manifest.res
โ”‚      โ”‚          โ”‚  runner.cxx.obj
โ”‚      โ”‚          โ”‚  test00.cxx.obj
โ”‚      โ”‚          โ”‚  test01.cxx.obj
โ”‚      โ”‚          โ”‚  test02.cxx.obj
โ”‚      โ”‚          โ”‚  test04.cxx.obj
โ”‚      โ”‚          โ”‚  test07.cxx.obj
โ”‚      โ”‚          โ”‚  test10.cxx.obj
โ”‚      โ”‚          โ”‚  test11.cxx.obj
โ”‚      โ”‚          โ”‚  test13.cxx.obj
โ”‚      โ”‚          โ”‚  test14.cxx.obj
โ”‚      โ”‚          โ”‚  test16.cxx.obj
โ”‚      โ”‚          โ”‚  test17.cxx.obj
โ”‚      โ”‚          โ”‚  test18.cxx.obj
โ”‚      โ”‚          โ”‚  test20.cxx.obj
โ”‚      โ”‚          โ”‚  test21.cxx.obj
โ”‚      โ”‚          โ”‚  test26.cxx.obj
โ”‚      โ”‚          โ”‚  test29.cxx.obj
โ”‚      โ”‚          โ”‚  test30.cxx.obj
โ”‚      โ”‚          โ”‚  test32.cxx.obj
โ”‚      โ”‚          โ”‚  test37.cxx.obj
โ”‚      โ”‚          โ”‚  test39.cxx.obj
โ”‚      โ”‚          โ”‚  test46.cxx.obj
โ”‚      โ”‚          โ”‚  test56.cxx.obj
โ”‚      โ”‚          โ”‚  test60.cxx.obj
โ”‚      โ”‚          โ”‚  test61.cxx.obj
โ”‚      โ”‚          โ”‚  test62.cxx.obj
โ”‚      โ”‚          โ”‚  test69.cxx.obj
โ”‚      โ”‚          โ”‚  test70.cxx.obj
โ”‚      โ”‚          โ”‚  test71.cxx.obj
โ”‚      โ”‚          โ”‚  test72.cxx.obj
โ”‚      โ”‚          โ”‚  test74.cxx.obj
โ”‚      โ”‚          โ”‚  test75.cxx.obj
โ”‚      โ”‚          โ”‚  test76.cxx.obj
โ”‚      โ”‚          โ”‚  test77.cxx.obj
โ”‚      โ”‚          โ”‚  test78.cxx.obj
โ”‚      โ”‚          โ”‚  test79.cxx.obj
โ”‚      โ”‚          โ”‚  test82.cxx.obj
โ”‚      โ”‚          โ”‚  test84.cxx.obj
โ”‚      โ”‚          โ”‚  test87.cxx.obj
โ”‚      โ”‚          โ”‚  test88.cxx.obj
โ”‚      โ”‚          โ”‚  test89.cxx.obj
โ”‚      โ”‚          โ”‚  test90.cxx.obj
โ”‚      โ”‚          โ”‚  vc140.pdb
โ”‚      โ”‚          โ”‚
โ”‚      โ”‚          โ””โ”€unit
โ”‚      โ”‚                  test_array.cxx.obj
โ”‚      โ”‚                  test_binarystring.cxx.obj
โ”‚      โ”‚                  test_blob.cxx.obj
โ”‚      โ”‚                  test_cancel_query.cxx.obj
โ”‚      โ”‚                  test_column.cxx.obj
โ”‚      โ”‚                  test_composite.cxx.obj
โ”‚      โ”‚                  test_connection.cxx.obj
โ”‚      โ”‚                  test_cursor.cxx.obj
โ”‚      โ”‚                  test_encodings.cxx.obj
โ”‚      โ”‚                  test_errorhandler.cxx.obj
โ”‚      โ”‚                  test_error_verbosity.cxx.obj
โ”‚      โ”‚                  test_escape.cxx.obj
โ”‚      โ”‚                  test_exceptions.cxx.obj
โ”‚      โ”‚                  test_field.cxx.obj
โ”‚      โ”‚                  test_float.cxx.obj
โ”‚      โ”‚                  test_largeobject.cxx.obj
โ”‚      โ”‚                  test_nonblocking_connect.cxx.obj
โ”‚      โ”‚                  test_notification.cxx.obj
โ”‚      โ”‚                  test_pipeline.cxx.obj
โ”‚      โ”‚                  test_prepared_statement.cxx.obj
โ”‚      โ”‚                  test_range.cxx.obj
โ”‚      โ”‚                  test_read_transaction.cxx.obj
โ”‚      โ”‚                  test_result_iteration.cxx.obj
โ”‚      โ”‚                  test_result_slicing.cxx.obj
โ”‚      โ”‚                  test_row.cxx.obj
โ”‚      โ”‚                  test_separated_list.cxx.obj
โ”‚      โ”‚                  test_simultaneous_transactions.cxx.obj
โ”‚      โ”‚                  test_sql_cursor.cxx.obj
โ”‚      โ”‚                  test_stateless_cursor.cxx.obj
โ”‚      โ”‚                  test_strconv.cxx.obj
โ”‚      โ”‚                  test_stream_from.cxx.obj
โ”‚      โ”‚                  test_stream_to.cxx.obj
โ”‚      โ”‚                  test_string_conversion.cxx.obj
โ”‚      โ”‚                  test_subtransaction.cxx.obj
โ”‚      โ”‚                  test_test_helpers.cxx.obj
โ”‚      โ”‚                  test_thread_safety_model.cxx.obj
โ”‚      โ”‚                  test_time.cxx.obj
โ”‚      โ”‚                  test_transaction.cxx.obj
โ”‚      โ”‚                  test_transaction_base.cxx.obj
โ”‚      โ”‚                  test_transaction_focus.cxx.obj
โ”‚      โ”‚                  test_transactor.cxx.obj
โ”‚      โ”‚                  test_type_name.cxx.obj
โ”‚      โ”‚                  test_zview.cxx.obj
โ”‚      โ”‚
โ”‚      โ””โ”€Testing
โ”‚          โ””โ”€Temporary
โ”‚                  LastTest.log
โ”‚
โ””โ”€install
    โ””โ”€x64-Debug
        โ”œโ”€include
        โ”‚  โ””โ”€pqxx
        โ”‚      โ”‚  array
        โ”‚      โ”‚  array.hxx
        โ”‚      โ”‚  binarystring
        โ”‚      โ”‚  binarystring.hxx
        โ”‚      โ”‚  blob
        โ”‚      โ”‚  blob.hxx
        โ”‚      โ”‚  composite
        โ”‚      โ”‚  composite.hxx
        โ”‚      โ”‚  config-public-compiler.h
        โ”‚      โ”‚  connection
        โ”‚      โ”‚  connection.hxx
        โ”‚      โ”‚  cursor
        โ”‚      โ”‚  cursor.hxx
        โ”‚      โ”‚  dbtransaction
        โ”‚      โ”‚  dbtransaction.hxx
        โ”‚      โ”‚  errorhandler
        โ”‚      โ”‚  errorhandler.hxx
        โ”‚      โ”‚  except
        โ”‚      โ”‚  except.hxx
        โ”‚      โ”‚  field
        โ”‚      โ”‚  field.hxx
        โ”‚      โ”‚  isolation
        โ”‚      โ”‚  isolation.hxx
        โ”‚      โ”‚  largeobject
        โ”‚      โ”‚  largeobject.hxx
        โ”‚      โ”‚  nontransaction
        โ”‚      โ”‚  nontransaction.hxx
        โ”‚      โ”‚  notification
        โ”‚      โ”‚  notification.hxx
        โ”‚      โ”‚  params
        โ”‚      โ”‚  params.hxx
        โ”‚      โ”‚  pipeline
        โ”‚      โ”‚  pipeline.hxx
        โ”‚      โ”‚  pqxx
        โ”‚      โ”‚  prepared_statement
        โ”‚      โ”‚  prepared_statement.hxx
        โ”‚      โ”‚  range
        โ”‚      โ”‚  range.hxx
        โ”‚      โ”‚  result
        โ”‚      โ”‚  result.hxx
        โ”‚      โ”‚  robusttransaction
        โ”‚      โ”‚  robusttransaction.hxx
        โ”‚      โ”‚  row
        โ”‚      โ”‚  row.hxx
        โ”‚      โ”‚  separated_list
        โ”‚      โ”‚  separated_list.hxx
        โ”‚      โ”‚  strconv
        โ”‚      โ”‚  strconv.hxx
        โ”‚      โ”‚  stream_from
        โ”‚      โ”‚  stream_from.hxx
        โ”‚      โ”‚  stream_to
        โ”‚      โ”‚  stream_to.hxx
        โ”‚      โ”‚  subtransaction
        โ”‚      โ”‚  subtransaction.hxx
        โ”‚      โ”‚  time
        โ”‚      โ”‚  time.hxx
        โ”‚      โ”‚  transaction
        โ”‚      โ”‚  transaction.hxx
        โ”‚      โ”‚  transaction_base
        โ”‚      โ”‚  transaction_base.hxx
        โ”‚      โ”‚  transaction_focus
        โ”‚      โ”‚  transaction_focus.hxx
        โ”‚      โ”‚  transactor
        โ”‚      โ”‚  transactor.hxx
        โ”‚      โ”‚  types
        โ”‚      โ”‚  types.hxx
        โ”‚      โ”‚  util
        โ”‚      โ”‚  util.hxx
        โ”‚      โ”‚  version
        โ”‚      โ”‚  version.hxx
        โ”‚      โ”‚  zview
        โ”‚      โ”‚  zview.hxx
        โ”‚      โ”‚
        โ”‚      โ””โ”€internal
        โ”‚          โ”‚  array-composite.hxx
        โ”‚          โ”‚  callgate.hxx
        โ”‚          โ”‚  concat.hxx
        โ”‚          โ”‚  conversions.hxx
        โ”‚          โ”‚  encodings.hxx
        โ”‚          โ”‚  encoding_group.hxx
        โ”‚          โ”‚  header-post.hxx
        โ”‚          โ”‚  header-pre.hxx
        โ”‚          โ”‚  ignore-deprecated-post.hxx
        โ”‚          โ”‚  ignore-deprecated-pre.hxx
        โ”‚          โ”‚  libpq-forward.hxx
        โ”‚          โ”‚  result_iter.hxx
        โ”‚          โ”‚  result_iterator.hxx
        โ”‚          โ”‚  sql_cursor.hxx
        โ”‚          โ”‚  statement_parameters.hxx
        โ”‚          โ”‚  stream_iterator.hxx
        โ”‚          โ”‚  wait.hxx
        โ”‚          โ”‚
        โ”‚          โ””โ”€gates
        โ”‚                  connection-errorhandler.hxx
        โ”‚                  connection-largeobject.hxx
        โ”‚                  connection-notification_receiver.hxx
        โ”‚                  connection-pipeline.hxx
        โ”‚                  connection-sql_cursor.hxx
        โ”‚                  connection-stream_from.hxx
        โ”‚                  connection-stream_to.hxx
        โ”‚                  connection-transaction.hxx
        โ”‚                  errorhandler-connection.hxx
        โ”‚                  icursorstream-icursor_iterator.hxx
        โ”‚                  icursor_iterator-icursorstream.hxx
        โ”‚                  result-connection.hxx
        โ”‚                  result-creation.hxx
        โ”‚                  result-pipeline.hxx
        โ”‚                  result-sql_cursor.hxx
        โ”‚                  transaction-sql_cursor.hxx
        โ”‚                  transaction-transaction_focus.hxx
        โ”‚
        โ”œโ”€lib
        โ”‚  โ”‚  pqxx.lib
        โ”‚  โ”‚
        โ”‚  โ”œโ”€cmake
        โ”‚  โ”‚  โ””โ”€libpqxx
        โ”‚  โ”‚          libpqxx-config-version.cmake
        โ”‚  โ”‚          libpqxx-config.cmake
        โ”‚  โ”‚          libpqxx-targets-debug.cmake
        โ”‚  โ”‚          libpqxx-targets.cmake
        โ”‚  โ”‚
        โ”‚  โ””โ”€pkgconfig
        โ”‚          libpqxx.pc
        โ”‚
        โ””โ”€share
            โ””โ”€doc
                โ””โ”€libpqxx
                        accessing-results.md
                        binary-data.md
                        datatypes.md
                        escaping.md
                        getting-started.md
                        mainpage.md
                        parameters.md
                        performance.md
                        prepared-statement.md
                        streams.md
                        thread-safety.md

โš  ็„ถๅŽๅฐฑๅฏไปฅ็ผ–ไปฃ็ ไฝฟ็”จ pqxx.lib ไบ†ใ€‚้™คๆญคไน‹ๅค–๏ผŒๅœจ็ผ–่ฏ‘้กน็›ฎๆ—ถ่ฟ˜้œ€่ฆๆทปๅŠ  libpq.lib.

้™คๆญคไน‹ๅค–ๅฏไปฅ็œ‹ๅˆฐไปฅไธ‹ไธคไธช็›ฎๅฝ•๏ผŒ่ฟ™ไธคไธช็›ฎๅฝ•ๅพ…ไผš่ฆๅผ•ๅ…ฅๅˆฐ VS ๅทฅ็จ‹ไธญ๏ผš

  • include๏ผšD:\Documents\A_Source\OpenSource\libpqxx\out\install\x64-Debug\include

  • lib: D:\Documents\A_Source\OpenSource\libpqxx\out\install\x64-Debug\lib

  • ่ฟ˜้œ€ๅผ•ๅ…ฅ libpq.lib ็š„็›ฎๅฝ•ใ€‚

ไฝฟ็”จ

ไปฅไธ‹ไปฃ็ ๅฏ็›ดๆŽฅไฝฟ็”จ๏ผŒ่‡ชๆต‹ๆ˜ฏๆฒก้—ฎ้ข˜็š„ใ€‚

ๅฆ‚ๆžœๆœ‰็ผ–่ฏ‘ๆŠฅ้”™ C4996: '_Header_ciso646'๏ผŒๅ…ณ้—ญ ==SDLๆฃ€ๆŸฅ== ๅ†็ผ–่ฏ‘่ฏ•่ฏ•ใ€‚

ๅฆๅค–่กฅๅ……ไธ€็‚น๏ผŒ็ผ–่ฏ‘็š„PEๆ–‡ไปถ่ฟ่กŒๆ—ถไพ่ต–ๅพˆๅคšdll๏ผŒๅŒ…ๆ‹ฌไฝ†ไธ้™ไบŽ libpq.dllใ€libssl ็ญ‰๏ผŒๅฏไปฅ้€‰ๆ‹ฉ้ƒจ็ฝฒๅˆฐๅฆๅค–ไธ€ๅฐๆœบๅ™จไธŠ๏ผŒๅŒๆ—ถ้ƒจ็ฝฒ C++ ่ฟ่กŒๆ—ถๆ–‡ไปถใ€‚

#include <iostream>
#include <windows.h>
#include <pqxx/pqxx>
#include <pqxx/transaction>

int main(int argc, char* argv[])
{
    // (Normally you'd check for valid command-line arguments.)

    if (argc < 3)
    {
        printf("Usage:\n %s <username> <password>", argv[0]);
        exit(-1);
    }

    char conn[MAX_PATH];

    sprintf(conn, "postgresql://%s:%s@localhost/postgres", argv[1], argv[2]);

    try
    {
        pqxx::connection c{ conn };
        pqxx::work txn{ c };

        // For querying just one single value, the transaction has a shorthand method
        // query_value().
        //
        // Use txn.quote() to escape and quote a C++ string for use as an SQL string
        // in a query's text.
        pqxx::result res = txn.exec("SELECT * FROM pg_authid");

        for (int i = 0; i < res.size(); i++)
        {
            for(int j = 0; j < res[i].size(); j++)
                std::cout << "" << res[i].at(j) << '\t';

            std::cout << '\n';
        }
    }
    catch (std::bad_alloc const&)
    {
        std::cerr << "Out of memory!" << std::endl;
    }
    catch (pqxx::sql_error const& e)
    {
        std::cerr << "SQL error: " << e.what() << std::endl
            << "Query was: " << e.query() << std::endl;
    }
    catch (std::exception const& e)
    {
        std::cerr << "Exception: " << e.what() << std::endl;
    }
    catch (...)
    {
        std::cerr << "Unknown exception" << std::endl;
    }
}

ๅœจๅฎ‰่ฃ…postgresql็š„ๆœบๅ™จไธŠ่พ“ๅ‡บๅฆ‚ไธ‹ๆ‰€็คบ๏ผš

image-20231226110211758

Show your support

Give a โญ๏ธ if this project helped you!


This README was generated with โค๏ธ by readme-md-generator

conn-postgresql-cpp's People

Contributors

holdyounger avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.